Problem · Array
Count Max Num Teams 🥝
Learn this problemProblem statement
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
Function
countMaxNumTeams(skill: int[], teamSize: int, maxDiff: int) → intExamples
Example 1
skill = [3, 4, 3, 1, 6, 5]teamSize = 3maxDiff = 2return = 2
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
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026