Reported June 2026
Microsoftsliding window

Programmer Strings

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

A frequency map is what this Microsoft OA question comes down to, and it was reported in June 2026. Programmer Strings sounds like a string puzzle, but it's really a counting problem. You need to find the earliest window that holds the letters of "programmer" and the latest one, then count the gap between them. If you're taking it in the next day or two, learn the shape now. StealthCoder sits invisibly on your screen as a safety net if you blank during the live assessment, but the idea is simple once you see it.

The problem

A programmer string contains letters that can be rearranged to form the word programmer and is a substring of a longer string.
Note that the strings programmer, grammproer, and prozmerqgram are all classified as programmer strings by this definition.
Given a string, determine the number of indices that lie between the rightmost and leftmost programmer strings that it contains.

Function
programmerStrings(s: String) → int
Complete the function programmerStrings in the editor below.

Examples
Example 1
s = "programmerxxxprozmerqgram"
return = 3
In this example, indices 0 - 9 form one programmer string and indices 13 - 24 contain another.
There are 3 indices between the programmer strings, so the function will return 3.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The word programmer has 10 letters: p, r x3, o, g, a, m x2, e. A programmer string is a substring that contains at least those counts, with extra letters allowed, as the example prozmerqgram shows. So keep a count of the needed letters and slide a window. Find the leftmost minimal window that satisfies all counts, scanning from the left. Then scan from the right for the rightmost one. The answer is the number of indices strictly between the left window's end and the right window's start. The common pitfall is the off-by-one. In the example, the first ends at index 9 and the second starts at 13, so the gap is 3 (indices 10 to 12). Another trap is assuming the windows must be exactly 10 long. They can't be, because extra letters are allowed. If you freeze on the window logic live, StealthCoder can give you a working version as a hedge.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Programmer Strings 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 passed his OA cold and still thinks the filter is broken.

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 passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Programmer Strings FAQ

What's the trick in Programmer Strings?+

Treat it as a character-count window problem. Build the required counts for "programmer" (r appears 3 times, m 2 times, the rest once). Slide a window until all counts are met. Do it from the left for the first match and from the right for the last match, then subtract indices.

How hard is this Microsoft OA question really?+

Medium at most. There's no fancy data structure beyond a frequency array or hash map. The difficulty is in the off-by-one on the gap and in remembering that extra letters are allowed inside the window, not only exact anagrams.

How do I count the indices between the two strings?+

Take the start index of the rightmost window minus the end index of the leftmost window, minus 1. In the example, the left ends at 9 and the right starts at 13, so 13 - 9 - 1 = 3. Check this against the sample before submitting.

What if there's only one programmer string, or none?+

The problem text doesn't say, so test it yourself. If only one window exists, left and right are the same, so the gap logic breaks. Decide what you return for that case, such as 0, and handle the no-match case explicitly instead of letting indices go negative.

How do I prepare for this in 48 hours?+

Practice the fixed-need sliding window pattern: a need-count array, a running count, and a matched-letters tracker. Write it once from the left, then mirror it from the right. Run the sample by hand. That's enough prep for this question.

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