Solution with no extra space


  • 0
    N
    class Solution(object):
        def singleNumber(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            nums.sort()
            for i in range(len(nums)/2):
                if nums[i*2] != nums[i*2+1]:
                    return nums[i*2]
            return nums[-1]
    

Log in to reply
 

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