Equalize Team Size
Learn this problemProblem statement
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
equalizeTeamSize(teamSize: int[], k: int) → int
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
Examples
Example 1
teamSize = [1, 2, 2, 3, 4]k = 2return = 4
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.
Constraints
More IBM problems
- Parent Process NumberOA · Seen Jul 2026
- Request Retry CountOA · Seen Jul 2026
- Count Strictly Increasing Subsequences of Length 3OA · Seen Jul 2026
- Maximum Requests in a Time WindowOA · Seen Jul 2026
- Query Type Frequency WindowOA · Seen Jul 2026
- Minimum Number of Non-Empty Disjoint SegmentsOA · Seen Jul 2026
- Spam Text ClassificationOA · Seen Jul 2026
- Count Ideal NumbersOA · Seen Jun 2026