728x90
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public int solution(int[] A) { // write your code in Java SE 8 HashSet<Integer> hs = new HashSet<>(); for (int a : A) hs.add(a); int v = 0; for (int i = 0; i < A.length; i++) { v++; if (hs.remove(v)) continue; else return v; } return ++v; } | cs |
'알고리즘 풀이 > Codility' 카테고리의 다른 글
codility - GenomicRangeQuery (Prefix Sums) (0) | 2019.12.10 |
---|---|
codility - PassingCars (Prefix Sums) (0) | 2019.12.10 |
codility - Counting Elements (PermCheck) (0) | 2019.12.10 |
codility - Counting Elements (MaxCounters) (0) | 2019.12.10 |
codility - Counting Elements (FrogRiverOne) (0) | 2019.12.10 |