Last active
January 9, 2020 16:32
-
-
Save qodirovshohijahon/a5f69e16659f6019a075236c030cd475 to your computer and use it in GitHub Desktop.
In this example it is described how to specify unique numbers in array through XOR(bitwise).
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
let result = 0; | |
let arr = [1, 2, 5, 4, 6, 1, 2, 5, 4]; | |
for(let i = 0; i <= arr.length; i++){ | |
result = result ^ arr[i]; | |
} | |
console.log(" this is an unique number " + result); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment