c++(47ms) sorting & 4 pointers
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n  int maxFrequency(vector<int>& nums, int k, int numOperations) {\n    sort(nums.begin(), nums.end());\n    \n    int ans = 1;\n    for(int l = 0, c = 0, d = 0, r = 0; c != nums.size(); c = d){\n\n      while(++d != nums.size() && nums[d] == nums[c]);\n      while(nums[l] + k < nums[c]) l++;\n      while(r != nums.size() && nums[r] <= nums[c] + k) r++;\n      \n      ans = max(ans, d - c + min(c - l + r - d, numOperations));\n    }\n\n    for(int l = 0, r = 1; ; ){\n      if(r == l) r++;\n      while(r != nums.size() && (long)nums[r] <= (long)nums[l] + k + k) r++;\n      \n      ans = max(ans, min(r - l, numOperations));\n      if(r == nums.size()) break;\n      while(++l != r && nums[l] == nums[l-1]);\n    }\n\n    return ans;        \n  }\n};\n```
['C++']