Record a Best Solution

Posted by Yan on February 25, 2015

Recently, when I played on LeetCode.com, there is a solution for a question is really beautiful. In this post, I want to present this solution.

The question is:

leetcode

The solution is:

public int singleNumber(int[] A) {
    int result = 0; 
    for (int i : A) result ^= i ; 
    return result ; 
}