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
// you can also use imports, for example:
// import java.util.*;
// you can write to stdout for debugging purposes, e.g.
// System.out.println("this is a debug message");
import java.util.*;
class Solution {
public int solution(int[] A) {
HashSet<Integer> hsSetIndex = new HashSet<Integer>();
for(int i= 0 ; i < A.length ; i++)
{
hsSetIndex.add(A[i]);
}
return hsSetIndex.size();
}
}
'Developer > Algorithm' 카테고리의 다른 글
[codility_] MaxProductOfThree (0) | 2020.12.05 |
---|---|
[codility_] PassingCars (0) | 2020.12.04 |
[codility_] GenomicRangeQuery-다시 (0) | 2020.12.02 |
[codility_] CountDiv (0) | 2020.12.01 |
[codility_] PermCheck (0) | 2020.12.01 |