Back to course home
0% completed
Count Elements With Maximum Frequency (easy)
Problem Statement
Given an array of positive integers named nums
, return the total frequencies of the elements in nums
that have a maximum frequency.
The frequency of an element is defined as the number of times that element is repeated in the array.
Examples
Example 1:
- Input: nums =
[3, 2, 2, 3, 1, 4]
- Output: 4
- Explanation: Both 2 and 3 appear twice, which is the highest frequency. So, the total frequency is 2 + 2 = 4.
Example 2:
- Input: nums =
[5, 5, 5, 2, 2, 3]
- Output: 3
- Explanation: The number 5 appears three times, which is the highest frequency. So, the total frequency is 3.
Example 3:
- Input: nums =
[7, 8, 8, 7, 9, 9]
- Output: 6
- Explanation: All elements appear twice. So, total maximum frequency is 2 + 2 + 2 = 6.
Constraints:
- 1 <= nums.length <= 100
- 1 <= nums[i] <= 100
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
Mark as Completed
Table of Contents
Problem Statement
Examples
Try it yourself