Skip to content

Instantly share code, notes, and snippets.

@clarkdo
Created January 29, 2018 08:05
Show Gist options
  • Save clarkdo/ece06d1a3075883659d951391ee7999d to your computer and use it in GitHub Desktop.
Save clarkdo/ece06d1a3075883659d951391ee7999d to your computer and use it in GitHub Desktop.
class Solution {
public int solution(int[] A) {
int min = A.length + 1;
int length = A.length;
boolean[] appearance = new boolean[length];
for (int i = 0; i < length; i++) {
if (A[i] > 0 && A[i] <= length) {
appearance[A[i]-1] = true;
}
}
for (int i = 0; i < length; i++) {
if (!appearance[i]) {
min = i + 1;
break;
}
}
return min;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment