A two-part screen that looks like a warm-up and isn't. Part one is the classic stack validator with three bracket types; part two flips to generating every valid string of n pairs, and the Catalan count is the detail that catches people off guard.
← Coding & DSA / 87
mediumMetaAmazonMicrosoft
Valid parentheses, then generate all valid combinations
A two-part screen that looks like a warm-up and isn't. Part one is the classic stack validator with three bracket types; part two flips to generating every valid string of n pairs, and the Catalan count is the detail that catches people off guard.
Updated Aug 2026 · Grounded in real Forward Deployed Engineer interview loops and written to a senior-engineer editorial bar.
20 answers per topic instead of 10, plus saved progress and bookmarks · no cardor unlock all 528 remaining answers · ₹2,000 / $25
UP NEXT ON YOUR JOURNEY
FEDITOR'S NOTE
The pivot from validation to generation is deliberate: the interviewer wants to see you switch from a linear scan to a backtracking search without restarting your thinking. The reliable filter is whether you prune with the open/close counters instead of generating all 2^(2n) strings and validating each.
DISCUSSION · 0
No comments yet — be the first to share your approach.
