Zero extra memory, O(n), Java


  • 0
    Y
     public int singleNumber(int[] nums) {
            for(int i = 1; i < nums.length; i++)
                nums[i] ^= nums[i-1];
            return nums[nums.length-1];
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.