Java Line Sweep Solution
Code\njava []\nclass Solution {\n    public int maxFrequency(int[] nums, int k, int numOperations) {\n        int sum = 0, maxFreq = 0;\n        Set<Integer> s 
# Code\n```java []\nclass Solution {\n    public int maxFrequency(int[] nums, int k, int numOperations) {\n        int sum = 0, maxFreq = 0;\n        Set<Integer> s = new TreeSet<>();\n        Map<Integer, Integer> freq = new HashMap<>(), m = new HashMap<>();\n        for(int i: nums){\n            freq.put(i, freq.getOrDefault(i, 0) + 1);\n            m.put(i - k, m.getOrDefault(i - k, 0) + 1);\n            m.put(i + k + 1, m.getOrDefault(i + k + 1, 0) - 1);\n            s.add(i);s.add(i - k);s.add(i + k + 1);\n        }\n        for(int key: s){\n            sum += m.getOrDefault(key, 0);\n            int curr = freq.getOrDefault(key, 0);\n            maxFreq = Math.max(maxFreq, curr + Math.min(numOperations, sum - curr));\n        }\n        return maxFreq;\n    }\n}\n```
['Java']