Description
Solutions
Count Max Num Teams π₯
π₯ FULLTIMEπRELATED PROBLEMS
Amazon is hosting a team hackathon.
- 1. Each team will have exactly teamSize developers.
- 2. A developer's skill level is denoted by
skill[i]
. - 3. The difference between the maximum and minimum skill levels within a team cannot exceed a threshold,
maxDiff
.
Determine the maximum number of teams that can be formed from the contestants.
Complete the function countMaxNumTeams
which has the following parameters
int skill[n]
: the developers' skill levelsint teamSize
: the number of developers to make up a teamint maxDiff
: the threshold value.
int
: the maximum number of teams that can be formed at one time
Example 1:

Input: skill = [3, 4, 3, 1, 6, 5], teamSize = 3, maxDiff = 2
Output: 2
Explanation:At most, 2 teams can be formed: [3, 3, 1] and [4, 6, 5].The difference between the maximum and minimum skill levels is 2 in each case, which does not exceed the threshold value of 2 π¦ Credit to Λκ°α mehh ΰ»κ±Λ π¦
Constraints:
-
1 β€ teamSize β€ n β€ 105
-
1 β€ maxDiff β€ 109
-
1 β€ skill[i] β€ 109
- Only one valid answer exists.


Related Problems
Testcase
Result
Case 1
input:
output: