FDEInterviews logoFDE/Interviews
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.

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.

Unlock the other 466 answers · ₹2,000 / $25Your progress and mastery stay saved · 6 months · one payment · no auto-renew
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.