[Python3] Line Sweep
Intuition\nFull doc of line sweep:\nhttps://leetcode.com/discuss/study-guide/2166045/line-sweep-algorithms\n\n# Approach\nline sweep\n\n# Complexity\n- Time com
# Intuition\nFull doc of line sweep:\nhttps://leetcode.com/discuss/study-guide/2166045/line-sweep-algorithms\n\n# Approach\nline sweep\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\n```python3 []\nclass Solution:\n    def maxFrequency(self, nums: List[int], k: int, numOperations: int) -> int:\n        visited = set(nums)\n        c = Counter(nums)\n        nums = [[num-k,num,num+k] for num in nums]\n        nums.sort()\n        d = defaultdict(int)\n\n        for start, mid, end in nums:\n            d[start] += 1\n            d[end + 1] -= 1\n            d[mid] += 0\n        \n        count = 0\n        ans = 0\n\n        for key in sorted(d.keys()):\n            count += d[key]\n            if key in visited:\n                ans = max(ans, c[key] + min(count - c[key], numOperations))\n            else:\n                ans = max(ans, min(count, numOperations))\n        \n        return ans\n```
['Python3']