Skip to Main Content

Single Number

Problem URL:Single Number

My Solution

Python

def singleNumber(nums: List[int]) -> int:
    stack = []

    for n in nums:
        if n in stack:
            i = stack.index(n)
            stack.pop(i)
        else:
            stack.append(n)

    return stack[0]

Let's Connect

Twitter GitHub LinkedIn