Count Max Num Teams

Problem Overview

  • Determine the maximum number of teams such that each team has exactly teamSize and the difference between max and min skill in a team is at most maxDiff.
  • Input: int array skill[n], int teamSize, int maxDiff. Output: int count of teams formed at one time.
  • Constraints: 1 ≤ teamSize ≤ n ≤ 1e5; 1 ≤ maxDiff, skill[i] ≤ 1e9; only one valid answer.
  • Real-world context: forming balanced hackathon teams.
  • From Amazon interviews; a coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: