Skip to content

Practice Apply Operations to Maximize Frequency Score

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

Hard#2968
LeetCode Problem

Apply Operations to Maximize Frequency Score

Problem Statement

In one operation, increase or decrease one nums entry by 1. Use at most k operations. Return the greatest frequency of any value that can occur in the resulting array.

Source: Apply Operations to Maximize Frequency Score on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,2,6,4], k = 3
Output
3

# Example 2

Input
nums = [1,4,4,2,4], k = 0
Output
3

Constraints

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

Related LeetCode Problems

Practice more problems similar to Apply Operations to Maximize Frequency Score.

Review your practice with PhantomCodeAI

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