in the video we used bit-wise operator can we use any other method
Unique number lesson question
@naaz, there are many ways to solve this problem ,
-
Bruteforce way :-
for every element check if it occurs again or not , if not that its the unique number.
Time Complexity O(n^2) Space Complexity O(1) -
Use map and store the frequency of each element by having key as the element itself and incrementing the map by one at every encounter and if there is an element with frequency 1 then that’s our answer
Time Complexity O(n) Space Complexity O(n)