Altiora Petamus

Perm Check ๋ณธ๋ฌธ

1day-1algorithm

Perm Check

Haril Song 2021. 8. 23. 18:36

PermCheck coding task - Learn to Code - Codility

 

PermCheck coding task - Learn to Code - Codility

Check whether array A is a permutation.

app.codility.com

 

๐Ÿค”์ƒ๊ฐํ•ด๋ณด๊ธฐ

์ฃผ์–ด์ง„ ๋ฐฐ์—ด์ด ์ˆœ์—ด์ด ๋งž๋Š”์ง€ ๊ฒ€์‚ฌํ•˜๋Š” ๋ฌธ์ œ

set() ์œผ๋กœ ๋ณ€ํ™˜ ํ›„ ๋น„๊ตํ•˜๋ฉด ์ˆœ์„œ์— ์ƒ๊ด€์—†์ด ๋™๋“ฑํ•œ์ง€ ๋น„๊ต๊ฐ€ ๊ฐ€๋Šฅํ•˜๋ฏ€๋กœ ๊ฐ„๋‹จํ•˜๊ฒŒ ํ•ด๊ฒฐ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

def solution(A):
    n = set([i for i in range(1, len(A) + 1)])
    return 1 if n == set(A) else 0

 

 

'1day-1algorithm' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

์œ ์ง„์ˆ˜  (0) 2021.08.27
์• ๋„ˆ๊ทธ๋žจ ๋งŒ๋“ค๊ธฐ  (0) 2021.08.26
DNA  (0) 2021.08.22
์„ธ๋กœ์ฝ๊ธฐ  (0) 2021.08.17
ํŒŒ์ผ๋ช… ์ •๋ ฌ  (0) 2021.08.13