filmov
tv
Find the element that appears once where every other element occurs thrice in an array

Показать описание
Hello Guys, Here I have discussed a problem which is asked by many tech giants like Google in their onsite interview.
Problem Description: Given an array of non-negative integers. Find the element that appears once where every other element occurs thrice in an array.
Solutions Discussed:
Approach 1: Brute Force approach
Time Complexity: O(n^2)
Space Complexity: O(1)
Approach 2: Using Hashmaps
Time Complexity: O(n)
Space Complexity: O(n)
Approach 3: Set bits method
Time Complexity: O(nlog(N))
Space Complexity: O(1)