Share runnable code, everywhere.
1
2
3
4
5
6
7
8
9
class Solution:
    def singleNumber(self, nums):
        ans = 0
        for n in nums:
            ans ^= n
        return ans
        
ans = Solution()
print(ans.singleNumber([4,1,2,1,2,3,3]))