Find the highest/lowest frequency element
Hashing DSA practice problem on Onlearn.
Difficulty: easy.
Topics: Finding the Highest and Lowest Frequency Element in an Array, Arrays, Hashing, Frequency Counting, Loops, Conditional Statements, Time Complexity, Space Complexity, Map, Hash Tables, brute force, hashing, frequency counting, hash map, time complexity analysis, Hashing & Hash Maps.
Find Highest and Lowest Frequency Elements in an Array Problem Statement Given an array of N integers, find the element with the highest frequency and the element with the lowest frequency. Input Specification The first line contains an integer N, the size of the array. The second line contains N space separated integers representing the elements of the array. Output Specification Print two space separated integers: the element with the highest frequency, followed by the element with the lowest frequency. If there are multiple elements with the highest or lowest frequency, any one of them can be printed. Sample Test Cases Example 1: Input: Output: Explanation: The frequency of 10 is 3 (highest) and the frequency of 15 is 1 (lowest). Example 2: Input: Output: Explanation: The frequency of 2 is 3 (highest) and the frequency of 3 is 1 (lowest).