Single Number

1     int singleNumber(int A[], int n) {
2         if(A==NULL||n<=0)//这是个好习惯,防止程序崩溃
3             return 0;
4         int i;
5         int result=A[0];
6         for(i=1;i<n;++i)
7             result ^= A[i];
8         return result;
9     }

 

posted on 2014-03-19 15:23  crane_practice  阅读(92)  评论(0编辑  收藏  举报

导航