3242. Count Elements With Maximum Frequency
My accepted Python solution to LeetCode problem 3242, Count Elements With Maximum Frequency, running in 4ms.
- Difficulty: Easy
- Python
- Runtime 4ms
- Memory 17.1MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 4ms, memory 17.1MB, accepted 2025-12-29.
class Solution:
def maxFrequencyElements(self, nums: List[int]) -> int:
from collections import Counter
freq = Counter(nums)
max_freq = max(freq.values())
return sum(v for v in freq.values() if v == max_freq)