python 46ms answer


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

Log in to reply
 

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