Skip to content

Instantly share code, notes, and snippets.

@qodirovshohijahon
Last active January 9, 2020 16:32
Show Gist options
  • Save qodirovshohijahon/a5f69e16659f6019a075236c030cd475 to your computer and use it in GitHub Desktop.
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).
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