Skip to content

Instantly share code, notes, and snippets.

@le-doude
Created June 19, 2014 05:10
Show Gist options
  • Save le-doude/96cd9a59f71b592b2771 to your computer and use it in GitHub Desktop.
Save le-doude/96cd9a59f71b592b2771 to your computer and use it in GitHub Desktop.
My solution to the https://codility.com/demo/take-sample-test/perm_missing_elem problem. solved in 30ssec flat!
class Solution {
public int solution(int[] A) {
int r = 0;
for (int i = 1; i <= A.length + 1; i++) {
r = r ^ i;
}
for (int i = 0; i < A.length; i++) {
r = r ^ A[i];
}
return r;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment