Binary Search On Answers || O(nlogn) || n <= 10^5
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 check(vector<int>& nums,int n, int t, int m){\n        int l = lower_bound(nums.begin(), nums.end(), n) - nums.begin();\n        int h = upper_bound(nums.begin(), nums.end(), n) - nums.begin();\n        int ll = lower_bound(nums.begin(), nums.end(), n-t) - nums.begin();\n        int hh = upper_bound(nums.begin(), nums.end(), n+t) - nums.begin();\n        int res = (hh - h) + (l - ll);\n        return min(m,res) + (h-l);\n    }\n    int maxFrequency(vector<int>& nums, int k, int numOperations) {\n        int m = numOperations;\n        sort(nums.begin(), nums.end());\n        int ans = 1;\n        for(int i=0; i<nums.size()-1; i++){\n            ans = max(check(nums,nums[i],k,m), ans);\n            ans = max(check(nums,nums[i]-k,k,m), ans);\n            ans = max(check(nums,nums[i]+k,k,m), ans);\n        }\n        return ans;\n    }\n};\n```
['Array', 'Binary Search', 'Sorting', 'C++']