Exceptional Case in Input

7

2 3 4 4 4 2 3

Code is working only when the number of occurrences of an element is even. For odd occurrences, it is returning that element only(like in the above input). But shouldn’t the answer be 0 in such cases, since no number has the frequency as 1?

Can we use hashmap to solve this problem? By storing the number and its frequency as the 2 parameters?

Hello @JaiGaur actually the motive here is yo learn the concept with bit masking.
What is the output you are getting?

I’m getting 4 as the output for the given input(2 3 4 4 4 2 3)

Yeah 4 should be the output as all other elements are present2 times but 4 Is present 3 times.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.