Amazon Online Assessment 2021 (OA) - Group division

A university has admitted a group of n students with varying skill levels. To better accommodate the students, the university 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 students, where levels[i] represents the skill level of student 1. All students within a group must have a skill level within maxSpread, a specified range of one another. Determine the minimum number of classes that must be formed.

This is a companion discussion topic for the original entry at