Make as many elements equal as possible by using a limited number of increment operations.
You are given an integer array nums and an integer k.
In one operation, you may increment any element of the array by 1. You can perform at most k such operations in total.
Return the maximum possible frequency of any value in the array after performing at most k operations.
A value's frequency is the number of times it appears in the array.
The best result comes from choosing a target value and using available increments to raise smaller numbers up to that value. Your goal is to find the largest group of elements that can be made equal with no more than k total increments.
nums: an integer arrayk: the maximum number of increment operations allowed1 <= nums.length0 <= kExample 1
Input
nums = [1,2,4], k = 5
Output
3
Explanation
Increment 1 by 3 and 2 by 2 to make all elements 4. The frequency of 4 becomes 3.
Example 2
Input
nums = [1,4,8,13], k = 5
Output
2
Explanation
You can make either [1,4] both equal to 4 using 3 operations, or [4,8] both equal to 8 using 4 operations. No group of 3 can be equalized within 5 operations.
Example 3
Input
nums = [3,9,6], k = 2
Output
1
Explanation
With only 2 increments, no two numbers can be made equal.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.