找出数组中不重复的数

 @Test
    public void test() {
        int[] a = {1, 2, 3, 2, 1, 3, 4, 4, 6};
        System.out.println(singleNumber(a));


    }
    public int singleNumber(int[] A) {
        if(A == null || A.length == 0) {
            return -1;
        }
        int rst = 0;
        for (int i = 0; i < A.length; i++) {
            rst ^= A[i];
        }
        return rst;
    }

猜你喜欢

转载自www.cnblogs.com/fanBlog/p/12177370.html