python sliding windows 2 times, O(nlogn)
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)$$ -->\nO(nlogn)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(n)\n# Code\n```python3 []\nclass Solution:\n    def maxFrequency(self, nums: List[int], k: int, numOperations: int) -> int:\n        c=Counter(nums)\n        keys=sorted(c.keys())\n        l,r,res,s = 0,0,0,c[keys[0]]\n        for v in keys:\n            while v-keys[l]>k:\n                s-=c[keys[l]]\n                l+=1\n            while r+1<len(keys) and keys[r+1]-v<=k:\n                s+=c[keys[r+1]]\n                r+=1\n            res=max(res, min(s, c[v] + numOperations))\n        l,r,s = 0,0,0\n        while r<len(keys):\n            if keys[r]-keys[l]>2*k:\n                s-=c[keys[l]]\n                l+=1\n            else:\n                s+=c[keys[r]]\n                r+=1\n                res=max(res, min(s, numOperations))\n        return res\n        \n```
['Python3']