simply two set operation.
class Solution(object):
def singleNonDuplicate(self, nums):
odd_set =set(nums[0::2])
even_set =set(nums[1::2])
return next(iter(odd_set-even_set))
@ypochien This looks interesting, would you mind explaining a bit more?
I take it that you create two sets, one that holds every other number from 0, and the other from 1.
And then you take the difference between the sets and see which number is left, right?