Single Number II | 4 Methods | Leetcode
Techdose Techdose
176K subscribers
70,842 views
1.6K

 Published On Jun 22, 2020

This video explains a very important programming interview problem which is to find the non-repeating number in an array where all the elements are repeating 3 times except for one element.This is the follow up problem of the question where we are required to find the non-repeating number in an array. This problem can be solved by a number of processes and i have shown 4 methods to solve this problem in this video.The first method is a very intuitive one where we use a hashmap and count the frequency of elements and then traverse the map to return the element occuring only once.The second method is very intuitive as well which is by using sorting.We sort the array and then traverse to find the non-repeating element.The third method is by counting number of set bits.In this method, if the number of set bits for a given position is not a multiple of 3 then the given bit is set in our resultant number.In this way, we can simply form our resultant number.The fourth method is not intuitive at all.This is a bit manipulation method where we are taking 2 variables ONES and TWOS. Ones will be storing the element which occurs only once in the array.We will use a combination of Bitwise-XOR and Bitwise-AND operations to get the result.I have explained all the methods with proper examples and have also shown the code walk through at the end of the video. CODE LINK is present below as usual. If you find any difficulty or have any query then do COMMENT below. PLEASE help our channel by SUBSCRIBING and LIKE our video if you found it helpful...CYA :)

=================================================================
INSTAGRAM:   / surya.pratap.k  
LinkedIn:   / surya-pratap-kahar-47bb01168  
WEBSITE: https://techdose.co.in/
=================================================================

CODE LINK: https://gist.github.com/SuryaPratapK/...
OTHER PROBLEMs:-
Counting elements:    • Counting elements | Leetcode  

show more

Share/Embed