https://app.codility.com/programmers/lessons/4-counting_elements/perm_check/

 

PermCheck coding task - Learn to Code - Codility

Check whether array A is a permutation.

app.codility.com

 

  • 배열 A가 주어질 때, 순열이면 1을 반환하고 아니면 0 출력하기
  • O(N) or O(N * log(N))

 

def solution(A):
    if len(set(A)) != len(A):
        return 0

    if len(A) == max(A):
        return 1
    else:
        return 0

+ Recent posts