C++ Easy Solution
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 op) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n        map<int,int> mp;\n        for(int i=0;i<n;i++) mp[nums[i]]++;\n        if(op==0)\n        {\n            int ma=0;\n            for(auto it:mp)\n                {\n                    ma=max(ma,it.second);\n                }\n            return ma;\n        }\n        int ans=0;\n        for(int i=0;i<n;i++)\n            {\n                int val = nums[i];\n                int ind1 = lower_bound(nums.begin(),nums.end(),val-k)-nums.begin();\n                int ind2 = upper_bound(nums.begin(),nums.end(),val+k)-nums.begin();\n                if(ind2-ind1-mp[val]<=op) ans=max(ans,ind2-ind1);\n                else ans=max(ans,mp[val]+op);\n\n                 val = nums[i]+k;\n                 ind1 = lower_bound(nums.begin(),nums.end(),val-k)-nums.begin();\n                 ind2 = upper_bound(nums.begin(),nums.end(),val+k)-nums.begin();\n                if(ind2-ind1-mp[val]<=op) ans=max(ans,ind2-ind1);\n                else ans=max(ans,mp[val]+op);\n\n            \n            }\n\n        return ans;\n\n    }\n};\n```
['Binary Search', 'Sorting', 'C++']