Tuesday, December 1, 2015

[leetcode]Single Number

1
2
3
4
5
6
7
8
9
public class Solution {
    public int singleNumber(int[] nums) {
        int result = nums[0];
        for (int i = 1; i < nums.length; i++){
         result ^= nums[i];
        }
        return result;
    }
}

No comments:

Post a Comment