Back to DSA
Generate Parentheses
mediumGiven an integer n, produce every arrangement of n pairs of parentheses that is syntactically balanced.
Examples
Example 1:
Input:
n = 2Output:
["(())","()()"] Example 2:
Input:
n = 4Output:
["(((())))","((())())","((()))()","(()(()))","(()()())","(()())()","(())(())","(())()()","()((()))","()(()())","()(())()","()()(())","()()()()"]Hints
1234567