HackerRank is organizing a hackathon for all its employees.
A hackathon is a team event, and there are n
teams taking part. The number of employees in the nth team is denoted by teamSize[n]
. In order to maintain uniformity, the team size of at most k
teams can be reduced. Find the maximum number of teams of equal size that can be formed if team size is reduced optimally.
Function Description
Complete the function equalizeTeamSize
in the editor below.
equalizeTeamSize
has the following parameters:
int teamSize[n]
: the number of employees in each teamint k
: the maximum number of teams whose size can be reduced
Returns
int
: the maximum number of equal size teams possible
Example 1:
Input: teamSize = [1, 2, 2, 3, 4], k = 2
Output: 4
Explanation:The team size of the last 2 teams can be reduced to 2, thus
teamSize = [1, 2, 2, 2, 2]
. The maximum number of teams with equal size is 4.
- 1 β€ n β€ 2 * 10^5
- 1 β€ teamSize[i] β€ 10^9
- 0 β€ k β€ 10^9

input:
output: