题目 题目描述:给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现三次.找出那个只出现一次的元素. 说明:你的算法应该具有线性时间的复杂度.你可以不使用额外的空间来实现吗? 思路 题目要求线性复杂度,一般的算法做不到,不难想到用位运算.但怎么进行位运算,比较难想到. b = (b ^ x) & ~a; a = (a ^ x) & ~b; ^ 相当于除去原有元素,添加新元素, a &~ b 相当于从a集合中除去b集合中的所有元素. int len = nums.s…
Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?…