I count how many times each number appears in the array using a frequency counter (like collections.Counter). Then I find the maximum frequency among all elements. Finally, I add up the frequencies of all elements that appear with this maximum frequency. This gives the total number of elements in the array that have the maximum frequency.
class Solution:
def maxFrequencyElements(self, nums: List[int]) -> int: