본문 바로가기

IT/알고리즘

[코딜리티] - Lesson 4. MissingInteger

안녕하세요 남갯입니다.



public int solution(int[] A) {
// write your code in Java SE 8

int result = 1;

Map<Integer, Boolean> map = new HashMap<>();
for (int a : A) {
if (a > 0)
map.put(a, true);
}

for(int i = 0; i < map.keySet().size(); i++){
if(!map.containsKey(result)){
return result;
}
result ++;
}
return result;
}


https://app.codility.com/demo/results/trainingV3PH42-992/