2025-09-22 19:34:44 +0300 MSK
Count Elements With Maximum Frequency
Links
Code
class Solution:
def maxFrequencyElements(self, nums: List[int]) -> int:
max_freq, max_freq_count = 0, 0
freqs = [0] * 101
for num in nums:
freqs[num] += 1
for num, freq in enumerate(freqs):
if freq > max_freq:
max_freq, max_freq_count = freq, freq
elif freq == max_freq:
max_freq_count += freq
return max_freq_count