import java.util.Set; import java.util.stream.Collectors; import java.util.stream.IntStream; private static void getResult(int[] a) { Set set = IntStream.of(a).boxed().collect(Collectors.toSet()); int result = 1; while(set.contains(result)) { result++; } return result; }
Reference: https://stackoverflow.com/questions/26532081/codility-missinginteger-java