Created
January 29, 2018 07:13
-
-
Save clarkdo/421fce4bc31ee96fa05bd4a712e320a7 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 length = A.length; | |
boolean[] appearance = new boolean[length]; | |
int count = 0; | |
for (int i : A) { | |
int position = i-1; | |
if (i <= length && !appearance[position]) { | |
appearance[position] = true; | |
count++; | |
} | |
} | |
return count == length ? 1 : 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment