Apple /Algorithm
[Algorithm/Swift] Codility / Distinct
moon_0
2022. 12. 28. 01:55

문제
https://app.codility.com/programmers/lessons/6-sorting/distinct/
풀이
뭐지,,너무 쉬운거아냐 ㅇ_ㅇ ?
이렇게 푸는게 맞나,,,

주어진 배열에서 고유한 요소를 찾아 카운트를 리턴하면 됩니다.
Code O(N*log(N)) or O(N)
public func solution(_ A : inout [Int]) -> Int {
let arrayToSet = Set(A)
return arrayToSet.count
}
