22. Generate Parentheses

MediumBacktracking

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

Examples

Input: 3

Output: ["((()))","(()())","(())()","()(())","()()()"]

Explanation: The five well-formed combinations of 3 pairs.

Constraints

  • 1 <= n <= 8
Loading...

Run checks all cases above. Submit evaluates all test cases.