. What is the approach to finding the frequency of elements using a map-based solution?
Ans. Use a map to count occurrences of each element in an array efficiently.
Initialize an empty map (or dictionary) to store element frequencies.
Iterate through the array, updating the count for each element in the map.
Example: For array [1, 2, 2, 3], the map will be {1: 1, 2: 2, 3: 1}.
After processing, the map contains the frequency of each unique element.
This approach has a time complexity of O(n) and space complexity of O(k), where k is the number of unique elements.