leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

3005.cpp (441B)


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