Last active
August 11, 2018 01:19
-
-
Save gajayana/ed8647a28c01aa69fe7918e17cdc6c0a to your computer and use it in GitHub Desktop.
Codility: Odd Occurrences In Array
This file contains 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
// https://app.codility.com/demo/results/trainingTVUZAM-A4K/ | |
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
if (!Array.isArray(A)) return; | |
let res = 0; | |
for (let i of A) { | |
res ^= i; | |
} | |
return res; | |
} | |
console.log(solution([9,3,9,3,9,7,9])); | |
console.log(solution([10,7,10,7,9,7,7,8,8])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment