Simple C++ Solution
Approach\n1. Firstly, sort the array.\n2. Then \'freq\' is used to store the frequency of each element in nums\n3. set st is used to store all potential target 
# Approach\n1. Firstly, sort the array.\n2. Then \'freq\' is used to store the frequency of each element in nums\n3. set st is used to store all potential target numbers (num, num - k, num + k) for which the frequency can be maximized.\n4. Next we will find the number of elements within the specified range.\n5. `int oprn_req=min(range-freq[it],numOperations);` This will calculate how many numbers within the range need to be modified to match particular element (it). The result is limited by the number of allowed numOperations.\n\n# Complexity\n- Time complexity: O(n*logn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\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        map<int,int> freq;\n        for(auto &i:nums) freq[i]++;\n\n        set<int> st;\n        for(auto &it:nums){\n            st.insert(it-k);\n            st.insert(it);\n            st.insert(it+k);\n        }\n\n        int ans{};\n        for(auto &it:st){\n            // elements in range [it-k,it+k]\n            auto lb=lower_bound(nums.begin(),nums.end(),it-k);\n            auto ub=upper_bound(nums.begin(),nums.end(),it+k);\n            int range=distance(lb,ub);\n\n            int oprn_req=min(range-freq[it],numOperations);\n            ans=max(ans,oprn_req+freq[it]);\n        }\n        return ans;    \n    }\n};\n```
['C++']