Return every valid string made of n pairs of parentheses (every ( has a matching ) after it), listed in dictionary order (( comes before )). For n = 3: ((())), (()()), (())(), ()(()), ()()().
Example 1
Input:
generate_parentheses(3)
Output:
['((()))', '(()())', '(())()', '()(())', '()()()']
Example 2
Input:
generate_parentheses(1)
Output:
['()']
0 <= n <= 10No results yet
Run your code to check it against the examples, or submit to run every test.