ํฐ์คํ ๋ฆฌ ๋ทฐ
๐จ๐ป ์ฝ๋ฉํ
์คํธ/Codility
Lesson 4: Counting Elements → Perm Check
dirmathfl 2020. 6. 6. 22:31728x90
๋ฐ์ํ
๋ฌธ์
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
๋ฐ์ํ
'๐จโ๐ป ์ฝ๋ฉํ ์คํธ > Codility' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Lesson 5: Prefix Sums โ Genomic Range Query (0) | 2020.06.07 |
---|---|
Lesson 5: Prefix Sums โ Count Div (0) | 2020.06.07 |
Lesson 4: Counter Elements โ Missing Integer (0) | 2020.06.06 |
Lesson 4: Counter Elements โ Max Counters (0) | 2020.06.06 |
Lesson 4: Counting Elements โ Frog River One (0) | 2020.06.06 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ