https://app.codility.com/programmers/lessons/15-caterpillar_method/abs_distinct/
- 내림차순 배열 A이 주어질 때
- 절대 값으로 고유한 값들의 개수 구하기
- O(N) or O(N*log(N))
def solution(A):
res = []
for i in A:
res.append(abs(i))
res = list(set(res))
return len(res)
'코딩테스트 > Codility' 카테고리의 다른 글
[codility] Lesson 12. Euclidean algorithm - ChocolatesByNumbers (0) | 2022.08.13 |
---|---|
[codility] Lesson 10. Prime and composite numbers - MinPerimeterRectangle (0) | 2022.08.13 |
[codility] Lesson 10. Prime and composite numbers - CountFactors (0) | 2022.08.13 |
[codility] Lesson 9. Maximum slice problem - MaxSliceSum (0) | 2022.08.13 |
[codility] Lesson 9. Maximum slice problem - MaxProfit (0) | 2022.08.13 |