Problem · String
Generate Parentheses
Learn this problemProblem statement
Given n pairs of parentheses, return every well-formed sequence containing exactly those pairs.
Return the sequences in lexicographic order.
Function
generateParenthesis(n: int) → String[]Examples
Example 1
n = 3return = ["((()))","(()())","(())()","()(())","()()()"]These are all five balanced sequences using three pairs, ordered lexicographically.
Constraints
1 <= n <= 8