[leetcode]Single Number

见过。所以就用XOR就行了。

public class Solution {
    public int singleNumber(int[] A) {
        int a = A[0];
        for (int i = 1; i < A.length; i++)
        {
            a ^= A[i];
        }
        return a;
    }
}

  

posted @ 2013-10-07 23:57  阿牧遥  阅读(198)  评论(0)    收藏  举报