Description
Solutions
Equalize Team Size
πŸ‘©β€πŸŽ“ NEW GRAD

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:

  1. int teamSize[n]: the number of employees in each team
  2. int 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.

Constraints:
  • 1 ≀ n ≀ 2 * 10^5
  • 1 ≀ teamSize[i] ≀ 10^9
  • 0 ≀ k ≀ 10^9
Thumbnail 0
Testcase

Result
Case 1

input:

output: