Skip to Main Content

Single Number II

Problem URL:Single Number II

My Solution

Python

def singleNumber(nums: List[int]) -> int:
    hashmap = {}
    for n in nums:
        if n in hashmap:
            hashmap[n]+=1
        else:
            hashmap[n] = 1

    return [k for k, v in hashmap.items() if v == 1][0]

Let's Connect

Twitter GitHub LinkedIn