Q136Single Number
Since xor is commutative, just xor all elements in nums and get the single one.
O(n)
O(1)
public class Solution {
public int singleNumber(int[] nums) {
int result = 0;
for (int i = 0; i<nums.length; i++){
result ^=nums[i];
}
return result;
}
}