Easy to understand 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 numOperations) {\n        int n=nums.size();\n        unordered_map<int, int> f;\n        vector<pair<int, int>> actions;\n\n        for (auto x : nums) {\n            f[x]++;\n            actions.push_back({x - k, +1});\n            actions.push_back({x + k + 1, -1});\n        }\n\n        set<int> timestamps;\n        for (auto action : actions) {\n            timestamps.insert(action.first);\n        }\n        for (auto c : f) {\n            timestamps.insert(c.first);\n        }\n        sort(actions.begin(), actions.end());\n\n        int index = 0,overlap = 0, maxi = 0;\n\n        for (int t : timestamps) {\n            while (index < actions.size() && actions[index].first <= t) {\n                overlap += actions[index].second;\n                index++;\n            }\n\n            int currentCount = f.count(t) ? f[t] : 0;\n            int possibleCount = currentCount + min(numOperations, overlap - currentCount);\n            maxi = max(maxi, possibleCount);\n        }\n\n        return maxi;\n    }\n};\n```
['C++']