본문 바로가기
개발/알고리즘

[codility] PermCheck

by ny0011 2021. 2. 17.
반응형

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

sorting해서 index와 value 비교

def solution(A):
    # write your code in Python 3.6

    a = sorted(A)
    for i,v in enumerate(a):
        if i+1 != v:
            return 0
    return 1

'개발 > 알고리즘' 카테고리의 다른 글

[codility] MinAvgTwoSlice  (0) 2021.02.18
[codility] GenomicRangeQuery  (0) 2021.02.18
[codility] MissingInteger  (0) 2021.02.17
[codility]FrogRiverOne  (0) 2021.02.17
[codility] TapeEquilibrium  (0) 2021.02.16

댓글