LeetCode solutions

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

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 4ms, memory 17.1MB, accepted 2025-12-29.

python
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)

Source