Java Missing Integer
import java.util.Arrays;
public class Solution {
public static int missingInteger(int[] a) {
int min = 1;
int[] sorted = Arrays.stream(a).distinct().sorted().toArray();
for (int v : sorted) {
if (v > 0) {
if (min != v) {
break;
}
min++;
}
}
return min;
}
}
This records the positive numbers that exist, then returns the smallest positive value that is still missing.