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
Post a Comment