Company: Amazon_Scientist_27sep
Difficulty: medium
Minimum Classes for Skill Grouping Problem Description A technical academy has admitted n trainees and wants to split them into classes by skill. A placement examination gives every trainee a skill level, stored in the array levels , where levels[i] is the skill level of trainee i . All trainees in the same class must have skill levels within maxSpread of one another: for any two members of a class, the absolute difference of their skill levels is at most maxSpread . Every trainee belongs to exactly one class, and a class may contain any number of trainees, including just one. Determine the minimum number of classes that must be formed. Complete the function groupStudents(levels, maxSpread) , which returns that minimum. Input Format Read from standard input. n levels[0] levels[1] ... levels[n-1] maxSpread The first line contains the integer n , the number of trainees. Each of the next n lines contains one integer levels[i] . The last line contains the integer maxSpread . Output Format