#3005
Count Elements With Maximum Frequency
newbie · 180 · lc easy +15 · verified · 79.8% accepted · 1,083 likes · top 91%
Description
You are given an array nums of positive integers.
Return the total count of elements in nums that have the maximum frequency.
The frequency of an element is the number of times it appears in the array.
Example 1:
Input: nums = [1,2,2,3,1,4]
Output: 4
Explanation: The elements 1 and 2 have a frequency of 2 which is the maximum frequency in the array.
So the number of elements in the array with maximum frequency is 4.
Example 2:
Input: nums = [1,2,3,4,5]
Output: 5
Explanation: All elements of the array have a frequency of 1 which is the maximum.
So the number of elements in the array with maximum frequency is 5.
Code
1
2
3