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?