Created
March 23, 2018 16:37
-
-
Save nickcherry/72b4f0ca26c884741e4ef99bf9992806 to your computer and use it in GitHub Desktop.
Lonely Integer
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
function lonelyInteger(arr) { | |
return arr.reduce((acc, n) => acc ^ n); | |
} | |
const arr = [1, 4, 1, 2, 3, 4, 3]; | |
console.log(lonelyInteger(arr)); | |
// 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment