137. Single Number II - LeetCode Solution


Bit Manipulation

Python Code:

class Solution:
    def singleNumber(self, nums: List[int]) -> int:
        h = {}
        
        for i in nums:
            if i in h:
                h[i]+=1
            else:
                h[i] = 1
                
        
        for i in h:
            if h[i]==1:
                return i
        


Comments

Submit
0 Comments
More Questions

1372A - Omkar and Completion
159D - Palindrome pairs
981B - Businessmen Problems
1668A - Direction Change
1667B - Optimal Partition
1668B - Social Distance
88B - Keyboard
580B - Kefa and Company
960A - Check the string
1220A - Cards
897A - Scarborough Fair
1433B - Yet Another Bookshelf
1283B - Candies Division
1451B - Non-Substring Subsequence
1408B - Arrays Sum
1430A - Number of Apartments
1475A - Odd Divisor
1454B - Unique Bid Auction
978C - Letters
501B - Misha and Changing Handles
1496A - Split it
1666L - Labyrinth
1294B - Collecting Packages
1642B - Power Walking
1424M - Ancient Language
600C - Make Palindrome
1669D - Colorful Stamp
1669B - Triple
1669A - Division
1669H - Maximal AND