首页 > 编程语言 > 详细

找出数组中不重复的数

时间:2020-01-10 18:39:39      阅读:88      评论:0      收藏:0      [点我收藏+]
 @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;
    }

 

找出数组中不重复的数

原文:https://www.cnblogs.com/fanBlog/p/12177370.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!