Reported September 2024
Microsoft

Great Subsequences

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

Microsoft asked this in September 2024, and it's a subsequence problem that looks simpler than it plays. You have an array, and you need to count or construct subsequences that meet some condition. The trick isn't brute force enumeration. The trick is recognizing which property of the subsequence matters and whether you can compute it incrementally. If you blank on the pattern during the OA, StealthCoder will read the full problem and hand you the approach in real time. Right now, know this: subsequence problems almost always reduce to counting, dynamic programming, or greedy selection.

Pattern and pitfall

Subsequence problems at Microsoft typically hinge on one of two things: either you're counting subsequences that satisfy a constraint (like sum, length, or element property), or you're building the lexicographically greatest or smallest one. If it's a counting problem, you'll likely use DP where the state is the index and some property you're tracking. If it's a construction problem, greedy often works (pick the largest available element at each step, or pick greedily to satisfy a condition). Common pitfall: trying to enumerate all 2^n subsequences instead of computing the answer in polynomial time. Common miss: forgetting that a subsequence must respect the original order but doesn't need to be contiguous. During the live OA, if you stall on the state definition, StealthCoder bridges the gap by showing you a working solution and the DP recurrence, letting you code it and move on.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Great Subsequences 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Great Subsequences FAQ

What does 'great' mean in this context?+

Without the full problem text, 'great' likely means either lexicographically largest, numerically greatest sum, or longest among valid subsequences. Read the constraint carefully during the OA. It will define exactly which subsequences count as 'great.' This determines whether you use greedy selection or DP counting.

Is this a counting problem or a construction problem?+

If the problem asks 'how many' subsequences are great, it's counting. Use DP with memoization and a state that tracks your position and any constraint (sum, length, etc.). If it asks 'find' or 'return' a great subsequence, it's construction. Greedy works for most construction variants at Microsoft.

How hard is this compared to standard LeetCode?+

Subsequence problems feel harder because the state space is large, but the DP structure is almost always the same: for each element, decide to include it or skip it. Once you nail the state and recurrence, the code is five lines. Microsoft asks these because they test state management, not algorithm knowledge.

Can I solve this in the time limit without DP?+

Only if it's a pure greedy problem, which is rare for 'great' subsequences. If you must count or validate, DP is mandatory. A naive 2^n backtrack will timeout. If you can't see the DP fast, sketch the base cases and transitions on paper. Don't code blind.

What's the first thing I should do when I see this problem?+

Parse the examples. For each example, manually identify one 'great' subsequence, then identify one that isn't. This tells you the constraint. Then decide: am I counting or constructing. Only then do you pick DP or greedy. The problem statement is your roadmap.

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