Group Students (AS Intern, it may apply to other interns)

Problem Overview

  • Group trainees by skill so each class has members whose levels differ by at most maxSpread; return the minimum number of classes.
  • Input: levels[n] (skill levels) and maxSpread; Output: integer count of classes.
  • Constraints: 1 ≤ n ≤ 1e5, 1 ≤ levels[i] ≤ 1e9, 0 ≤ maxSpread ≤ 1e9.
  • Real-world context: Amazon Technical Academy classes tailored to trainee skill ranges.
  • From Amazon interviews; a coding interview problem and common interview question for interns.

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: