Skip to content

Instantly share code, notes, and snippets.

@ShinJJang
Created January 10, 2020 14:14
Show Gist options
  • Save ShinJJang/924f5815dc3cd5b8b01797de79c741ed to your computer and use it in GitHub Desktop.
Save ShinJJang/924f5815dc3cd5b8b01797de79c741ed to your computer and use it in GitHub Desktop.
class Solution {
public int solution(int X, int[] A) {
// write your code in Java SE 8
boolean[] checkArray = new boolean[X];
for(int i=0; i<A.length; i++) {
boolean is_leave = checkArray[A[i] - 1];
if (is_leave == false) {
checkArray[A[i]- 1] = true;
X -= 1;
if (X == 0) {
return i;
}
}
}
return -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment