Algorithm
Step 1: Create a map of integer to store key-value pairs. map<int,int>
Step 2: Now iterate over all the elements of the array and count their frequency by the help of map
Step 3: Now make a iterator for map to iterate over the map items
Step 4: This is the final step. Just print all the elements and their frequency stored in map respectively

Comments
Post a Comment