Single Number II
LeetCode Problem #137 (Medium)
Problem Statement
Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.
Testcases
Algorithm
Iterative Mapping Approach
Initialize a map to store the value of the element and the number of occurrences of the element in the array as a key-value pair.
Iterate through the array of elements and store the count of each element in the array.
Find the element in the array which has
count = 1
and return the value of that element.
Code
Last updated
Was this helpful?