Single Number
Q: 求出数组中只出现1次的数,其他数都出现2次。
int singleNumber(int A[], int n) { // Note: The Solution object is instantiated only once and is reused by each test case. int num = 0; for(int i=0;i<n;i++) num^=A[i]; return num; }
Q: 求出数组中只出现1次的数,其他数都出现2次。
int singleNumber(int A[], int n) { // Note: The Solution object is instantiated only once and is reused by each test case. int num = 0; for(int i=0;i<n;i++) num^=A[i]; return num; }