Created
June 19, 2014 05:10
-
-
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!
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 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