why is it failing at some testcases
Frequency map in array
hi @nirupama1 i dont know which question you are trying to solve so please share its link/description with me
we have to find the element with maximum frequency in a given array.
5
1 2 2 2 3
output 2
@nirupama1 iād suggest you to follow the following approach:
firstly use unordered_map to store frequency of elements.
Now you have key-value pairs for element-frequency
to find maximum frequency you can iterate over the map and update the maximum frequency variable. You can find the syntax here https://www.geeksforgeeks.org/unordered_map-in-cpp-stl/
Using a map is better than making an array for frequency because you dont know the range of the elements.