https://app.codility.com/programmers/lessons/6-sorting/distinct/

 

Distinct coding task - Learn to Code - Codility

Compute number of distinct values in an array.

app.codility.com

 

  • 배열 A가 주어질 때, 중복된 값들을 모두 제거하고 배열의 길이를 구한다.
  • O(N*log(N)) or O(N)
def solution(A):
    unique = list(set(A))
    return len(unique)

 

+ Recent posts