Question bank › Two Pointers
Dsa Two Pointers Easy

Roster Skill Gap

You are forming a team from a pool of players. Each player has a skill level, and the pool is provided as a sorted list of levels. A team is 'balanced' if the difference between the maximum and minimum skill level in the team is at most D. Find the maximum number of players you can include in a single balanced team. Input Format: Line 1: An integer D (the max allowed gap). Line 2: A space-separated list of sorted skill levels. Output Format: A single integer representing the maximum team size. Example: Input: 3 1 2 4 4 7 8 Output: 4 (Explanation: The team with levels [1, 2, 4, 4] has a max gap of 3. Size is 4.)

Key concepts

two_pointerssliding_window

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.