SingleNumber
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^0=A A^A=0 最后可求出SingleNumber
public class Solution {
public int singleNumber(int[] A) {
int res=0;
for(int i=0;i<A.length;i++){
res^=A[i];
}
return res;
}
}