Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
在数组中,数字皆成对出现,找出唯一一个单独的数字。
思路:a^a=0,相同数字异或为0.
1 public class Solution { 2 public int singleNumber(int[] A) { 3 if(A==null||A.length==0) 4 return 0; 5 int res=0; 6 for(int i=0;i