Single Number

Given an array of integers, every element appears twice except for one. Find that single one.
Could you implement it without using extra memory?
Intuitive answer: using hash set Without extra space: use bit XOR. All numbers which occur twice will be cancelled out by themselves.

Comments

Popular posts from this blog

Maximum Gap

[ITint5] Maximum Subarray for a Circular Array

[CC150] Chapter 4 Trees and Graphs