Did not get, how does this solution work and how to come up with such an approach
Unique numebers 3
While practising similar question, you will slowly be able to get the intuition behind such questions.
Just try to understand the idea behind the solution and not the solution.
For the solution part, The solution builds up the answer bit by bit, the sum of i’th bit of all numbers is calculated and if the sum is of the type 3k+1, that would implies that the answer have the i’th bit set. ( because the numbers which are present three times would imply sum of i’th bit is of type 3k, the unique number can only make the sum 3k+1 )