Skip to content

Practice Maximum Frequency of an Element After Performing Operations II

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#3347
LeetCode Problem

Maximum Frequency of an Element After Performing Operations II

Problem Statement

Given nums, k, and numOperations, perform exactly numOperations operations on distinct indices. At each chosen index, add any integer in the inclusive interval [-k, k], including zero. Return the largest frequency any value can have after all operations.

Source: Maximum Frequency of an Element After Performing Operations II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,4,5], k = 1, numOperations = 2
Output
2

# Example 2

Input
nums = [5,11,20,20], k = 5, numOperations = 1
Output
2

Constraints

1 <= nums.length <= 10^5
1 <= nums[i] <= 10^9
0 <= k <= 10^9
0 <= numOperations <= nums.length

Related LeetCode Problems

Practice more problems similar to Maximum Frequency of an Element After Performing Operations II.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.