You're given an array where every element appears twice except for one. Find that single element.
For example, returns . The constraint: solve it in time and space.
Think about XOR's properties. What happens when you XOR all the numbers together?
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
LeetCode 136
You're given an array where every element appears twice except for one. Find that single element.
For example, returns . The constraint: solve it in time and space.
Think about XOR's properties. What happens when you XOR all the numbers together?