Saturday, August 30, 2014

Single Number ||

Problem

Given an array of integers, every element appears three times except for one. Find that single one.

Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?

Idea

这是个数学题,使用两个变量one和two 的各个位来映射数组中每个元素的各个位,one代表出现1次,two代表出现了2次。See the following code

Solution


No comments:

Post a Comment