3005.cpp (441B)
1 class Solution { 2 public: 3 int maxFrequencyElements(const vector<int> &nums) const { 4 static int count[101]; 5 memset(count, 0x00, sizeof(count)); 6 7 for (const int n : nums) 8 count[n]++; 9 10 int res = 0, maxi = 0; 11 for (int i = 0; i <= 100; i++) { 12 if (count[i] == maxi) res += count[i]; 13 if (count[i] > maxi) res = maxi = count[i]; 14 } 15 return res; 16 } 17 };