class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ while len(nums)>0: a = nums.pop() if a not in nums: return a else: nums.remove(a)
It is actually O(n^2), but it could be tricky to see why. You have your outer while loop that will run len(nums) times. You also have looping structure inside of the while loop as well. Think about how "if a not in nums" would be implemented behind the scenes.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.