Search
⌘K
Get Premium
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).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.