FastPrepCount Max Num Teams 🥝
Problems/Count Max Num Teams 🥝

Count Max Num Teams 🥝

Amazon logoAmazon● EasyFULLTIMEOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Special thanks: mehh shared this example explanation.

Amazon is hosting a team hackathon.

  1. 1. Each team will have exactly teamSize developers.
  2. 2. A developer's skill level is denoted by skill[i].
  3. 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.

Complete the function countMaxNumTeams which has the following parameters

  • int skill[n]: the developers' skill levels
  • int teamSize: the number of developers to make up a team
  • int maxDiff: the threshold value.

int: the maximum number of teams that can be formed at one time

Function

countMaxNumTeams(skill: int[], teamSize: int, maxDiff: int) → int

Examples

Example 1

skill = [3, 4, 3, 1, 6, 5]teamSize = 3maxDiff = 2return = 2
Example 1 illustration

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

Constraints

  • 1 ≤ teamSize ≤ n ≤ 105
  • 1 ≤ maxDiff ≤ 109
  • 1 ≤ skill[i] ≤ 109
  • Only one valid answer exists.

More Amazon interview questions

  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximize Shipment Order by Sorting One WindowOA · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fill One Exact-Length Binary WindowOA · Seen Nov 2026
  • Lexicographically Largest IdentifierOA · Seen Nov 2026
  • LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximal SquareONSITE INTERVIEW · Seen Nov 2026
  • Minimum Grid InconvenienceOA · Seen Nov 2026

Similar questions at other companies

  • Minimum Parking Roof LengthAmerican Express · OAAmerican Express interview questions
  • Sliding Window MedianAuxoAI · OA
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Maximum Requests in WindowSalesforce · OASalesforce interview questions
  • Earliest Hour with Frequent Badge AccessIntuit · OAIntuit interview questions
  • Choose One from Each Set to Minimize the RangeInMobi · OAInMobi interview questions
  • Fairest Chocolate PacketsAdobe · PHONE SCREENAdobe interview questions
  • Integer Compression OffsetHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
  • Sliding Window Average After Trimming Both EndsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Detect Security Attacks from Network LogsFireworks AI · PHONE SCREEN

Interview reports that mention this question

  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int countMaxNumTeams(int[] skill, int teamSize, int maxDiff) {
      // write your code here
    }

}
Checking account…