Search
⌘K

Leetcode 22. Generate Parentheses

Generate all distinct well-formed parentheses strings formed from n pairs, i.e., all length-2n sequences where every prefix has at least as many '(' as ')'. This combinatorial generation problem is typically solved with backtracking/DFS by choosing to add '(' or ')' while tracking remaining opens/closes (result count grows as the nth Catalan number; n ≤ 8).

Asked at:

Microsoft

Microsoft


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Mid January, 2026

Microsoft

Microsoft

Junior

Comments

Your account is free and you can post anonymously if you choose.