https://app.codility.com/programmers/lessons/15-caterpillar_method/abs_distinct/
int solution(vector<int> &A) {
int sz = A.size();
for(int i=0; i<sz; i++){
A[i] = abs(A[i]);
}
sort(A.begin(),A.end());
A.erase(unique(A.begin(),A.end()),A.end());
return A.size();
}
'Codility' 카테고리의 다른 글
[Codility] Caterpillar method : CountTriangles (0) | 2021.07.16 |
---|---|
[Codility] Lesson15 - Caterpillar method: MinAbsSumOfTwo (0) | 2021.07.16 |
Codility TieRopes C++ (0) | 2021.07.15 |
Codility MaxNonoverlappingSegments C++ (0) | 2021.07.15 |