給出2*n + 1 個的數(shù)字,除其中一個數(shù)字之外其他每個數(shù)字均出現(xiàn)兩次,找到這個數(shù)字。
public class Solution {
/**
*@param A : an integer array
*return : a integer
*/
public int singleNumber(int[] A) {
// Write your code here
int num = 0;
for (int n : A){
//使用異或處理
num ^= n;
}
return num;
}
}