摘要: Given an array of integers, every element appearstwiceexcept for one. Find that single one.Could you implement it without using extra memory?[解题思路]以前看书时遇到过,一个数组中有一个元素出现一次,其他每个元素都出现两次要求空间复杂度为O(1)由于两个相同的元素异或的结果为0,而0^a==a,将数组中所有元素都进行异或,得到结果就是只出现一次的元素 1 public class Solution { 2 public int singleNum... 阅读全文
posted @ 2013-10-02 20:57 feiling 阅读(1080) 评论(2) 推荐(0) 编辑