Group Students (AS Intern, it may apply to other interns) π
See Amazon hiring insights
Amazon Technical Academy (ATA) provides in-demand, technical training to current Amazon employees looking to broaden their skill sets. ATA has admitted a group of n prospective trainees with varying skill levels. To better accommodate the trainees, ATA has decided to create classes tailored to the skill levels. A placement examination will return a skill level that will be used to group the trainees into classes, where levels[i] represents the skill level of trainee i. All trainees within a class must have a skill level within maxSpread, a specified range of one another. Determine the minimum number of classes that must be formed.
Complete the function groupStudents in the editor.
groupStudents has the following parameter(s):
int levels[n]: the skill level for each studentint maxSpread: the maximum allowed skill level difference between any two members of a class
Returns
int: the minimum number of classes that can be formed
levels = [1, 4, 7, 3, 4] maxSpread = 2 return = 3
maxSpread = 2 levels of each other. In this case, one optimal grouping is (1, 3), (4, 4), and (7). Another possible grouping is (1), (3, 4, 4), (7). There is no way to form fewer than 3 classes.1 <= n <= 105
1 <- levels[i] <= 109 for every i (where 0 <= i <= n - 1)
0 <= maxSpread <= 109
- Count Promotional PeriodsOA Β· Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA Β· Seen Jun 2026
- Find Minimum CostOA Β· Seen Jun 2026
- Get Smallest Base SegmentOA Β· Seen Jun 2026
- Select Least Resource TasksOA Β· Seen Jun 2026
- Product Category Group SizesPHONE SCREEN Β· Seen May 2026
- Count Connected ComponentsPHONE SCREEN Β· Seen May 2026
public int groupStudents(int[] levels, int maxSpread) {
// write your code here
}