Amazon Online Assessment 2021 (OA) - Count Maximum Teams

Amazon is hosting a team hackathon.

  1. Each team will have exactly teamSize developers.
  2. A developer's skill level is denoted by skill[i].
  3. The difference between the maximum and minimum skill levels within a team cannot exceed a threshold, maxDiff.

Determine the maximum number of teams that can be formed from the contestants.

Example

  • skill = [3, 4, 3, 1, 6, 5], teamSize = 3, maxDiff = 2: At most, 2 teams can be formed: [3, 3, 1] and [4, 6, 5]. The difference between the maximum and minimum skill levels is 2 in each case, which does not exceed the threshold value of 2.

Solution and Explanations

Title

Script

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.

Contrary to popular belief, Lorem Ipsum is not simply random text.

1  >>> a = [1, 2, 3]
2  >>> a[-1]
3  3

Get premium for instant access to all content and solutions

Upgrade