ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

728x90
๋ฐ˜์‘ํ˜•

๋ฌธ์ œ

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

๋ฆฌ์ŠคํŠธ์˜ ๊ฐ’์ด ์ˆœ์—ด์ธ์ง€ ํ™•์ธํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค.

๋ฌธ์ œ ํ’€์ด

Missing Integer์™€ ๋™์ผํ•œ ๋ฐฉ์‹์œผ๋กœ ํ’€๋ฉด ๋œ๋‹ค.

์ฝ”๋“œ

def solution(A):
    sort = sorted(A)
    check_num = 1
    for num in sort:
        if num == check_num:
            check_num += 1
    return 1 if len(A) == check_num - 1 else 0
728x90
๋ฐ˜์‘ํ˜•
๋Œ“๊ธ€
๊ธ€ ๋ณด๊ด€ํ•จ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€