Question link: https://practice.geeksforgeeks.org/problems/find-duplicates-in-an-array/1/?track=interview-arrays
Input:
25
6 23 8 19 13 22 9 23 16 8 2 11 22 1 15 1 22 22 8 5 11 19 8 11 5
Its Correct output is:
23 8 22 1 11 19 5
And Your Code’s output is:
1 5 8 11 19 22 23
Can you all see the difference? My output is right but since it is sorted I am getting Wrong Answer.
This is because I have used std::map<K,V> .
So when I iterate over it, it iterates based on the sorted order,
not the order that I inserted elements.
Can someone help? Is there any alternative?
Here is my code : https://ide.geeksforgeeks.org/eZKvGIdmXs