2968. Apply Operations to Maximize Frequency Score
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```\nclass Solution:\n    def maxFrequencyScore(self, nums: List[int], k: int) -> int:\n        res = 1\n        l = 0\n        curr = 0\n        nums.sort()\n        for r in range(len(nums)):\n            curr += nums[r] - nums[(r+l)//2]\n            while curr > k:\n                curr -= nums[ceil((r+l)/2)] - nums[l]\n                l += 1\n            res = max(res, r - l + 1)\n        return res\n              \n            \n```
['Python3']