Created
January 29, 2018 08:05
-
-
Save clarkdo/ece06d1a3075883659d951391ee7999d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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