Reported September 2026
Microsoftsliding window

Minimum Team Size From Every Start

Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Microsoft OA. Under 2s to a working solution.
Founder's read

With talent.length up to 200000, the obvious move is to expand a window from every start index, and that O(n^2) loop will die on the big tests. This Microsoft OA was reported in September 2026, and it asks for the shortest contiguous team starting at each index that holds every talent from 1 to talentsCount. It's a sliding window problem wearing a slightly unusual hat. If you recognize that shape fast, the rest is bookkeeping. StealthCoder sits invisibly on your screen as a safety net in case you blank mid-assessment.

The problem

Students stand in a fixed order. The integer talent[i] is the talent of the student at index i, and every talent is between 1 and talentsCount.
A valid team is a contiguous group that contains at least one student with each talent from 1 through talentsCount.
For every starting index i, find the minimum length of a valid team whose first student is at index i. Return an array answer of the same length as talent, where answer[i] is that minimum length. If no valid team can start at i, set answer[i] to -1.

Function
minimumTeamSizes(talent: int[], talentsCount: int) → int[]

Examples
Example 1
talent = [1,2,3,2,1]
talentsCount = 3
return = [3,4,3,-1,-1]
The shortest complete windows beginning at the first three indices have lengths 3, 4, and 3. The suffixes beginning at the last two indices omit at least one talent, so their answers are -1.

Constraints
1 <= talent.length <= 200000
1 <= talentsCount <= 200000
1 <= talent[i] <= talentsCount

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: for each start i, the minimal end e(i) never decreases as i increases. Removing the student at i can only push the needed end right or keep it. So run two pointers. Keep a count array of size talentsCount plus a distinct counter. Extend the right pointer until distinct equals talentsCount, record answer[i] as right minus i, then drop talent[i] and move on. Once the window can't be completed, every later start is -1, so fill the rest and stop. Pitfalls: off-by-one on length, forgetting to decrement the distinct counter when a count hits zero, and resetting the right pointer each iteration, which quietly brings back O(n^2). Also handle talentsCount larger than n, where every answer is -1. If you freeze on the live OA, StealthCoder gives you the pointer logic to check against.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Minimum Team Size From Every Start cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Microsoft's OA.

Microsoft reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Team Size From Every Start FAQ

What's the trick in Minimum Team Size From Every Start?+

Monotonic end pointer. The shortest valid window for start i ends at or after the one for start i-1. So one right pointer that never moves back, plus a frequency array and a distinct counter, solves it in O(n).

How hard is this Microsoft OA question really?+

Medium. The idea is standard sliding window, but the per-start output and the -1 cases trip people up. If you've done minimum window substring style problems, this is a small twist on that.

Why does brute force fail here?+

Both talent.length and talentsCount go up to 200000. Scanning from every start can touch about n squared elements, which is around 4 times 10^10 operations in the worst case. That times out. You need linear or n log n.

What edge cases should I test before submitting?+

talentsCount greater than the array length, which gives all -1. A single element with talentsCount 1, which gives [1]. Arrays where a talent appears only once near the start. And the tail where later indices must return -1 as in the example.

How do I prepare for this in 48 hours?+

Write the two-pointer window with a count array from memory twice. Then do one variant where you record an answer per start index instead of one global best. Practice the shrink step and the distinct counter update until they're automatic.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Microsoft.

OA at Microsoft?
Invisible during screen share
Get it