082-落单的数-容易-Java

题目

082-落单的数-容易-Java_第1张图片
落单的数.png

分析

通过异或,相同的数结果为0,那么最后的结果一定是落单的数字。

代码

public class Solution {
    /*
     * @param A: An integer array
     * @return: An integer
     */
    public int singleNumber(int[] A) {
        int answer = 0;
        for(int i=0; i

参考

http://www.cnblogs.com/JhSonD/p/6374397.html

你可能感兴趣的:(082-落单的数-容易-Java)