작은하마

[Codility] odd occurrences in array 본문

코딩테스트/Codility

[Codility] odd occurrences in array

꼬몽울 2021. 7. 23. 18:22

https://app.codility.com/programmers/lessons/2-arrays/odd_occurrences_in_array/start/

 

Codility

Your browser is not supported You should use a supported browser. Read more

app.codility.com

배열 A가 주어졌을때 짝이 맞지 않는 수를 반환하는 문제이다.

배열에서 하나의 숫자 빼고는 다 짝이 맞도록 설정이되어있다.

st=list(set(a))
for i in st:
    cnt=a.count(i)
    if cnt==1:
        answer=i
answer

처음에 이런식으로 접근을 하였는데

55점이 나왔다.

이유는 O(n**2) 시간복잡도가 만족하지 않은것...

 

'코딩테스트 > Codility' 카테고리의 다른 글

[Codility] 짝지어 제거하기  (0) 2021.07.26
[codility] FrogJmp  (0) 2021.07.23
[codility]디버깅문제  (0) 2021.07.22
[codility] 합이 같은 수  (0) 2021.07.22
[Codility] CyclicRotation  (0) 2021.07.21
Comments