Python - Easy to understand
\n# Code\npython3 []\nclass Solution:\n    def maxFrequency(self, nums: List[int], k: int, numOperations: int) -> int:\n        nums.sort()\n        c = default
\n# Code\n```python3 []\nclass Solution:\n    def maxFrequency(self, nums: List[int], k: int, numOperations: int) -> int:\n        nums.sort()\n        c = defaultdict(int)\n        for i in nums: c[i] +=1 \n            \n        def fun(num):\n            left = bisect_left(nums, num-k)\n            right = bisect_left(nums, num+k+1)\n            options = right-left-c[num]\n            return min(options, numOperations) + c[num]\n\n        ans = 0\n        for num in nums:\n            ans = max(ans, fun(num), fun(num+k))\n        return ans\n```
['Python3']