'''
int singleNumber(vector<int>& nums) {
int len=nums.size();
for(int l=1;l<len;l++)
nums[0]=nums[0]^nums[l];
return nums[0];
}
'''
Without using extra space, just a trick

@newgang cool trick, although I don't think it may work if nums[0] is not equal to 0.
In an attempt to improve on your concept, here's my javascript approach(refactored), although it changes the content of the array, which I am not sure is what we want.
var singleNumber = function(nums) { for(var i = 0; i < nums.length; i++){ if(i === 0){ nums[0] = 0 ^ nums[0]; }else{ nums[0] ^= nums[i]; } } return nums[0]; };

@tgreenidge
The FOR loop starts from i=1, so it does not depend on the value of nums[0].

