mediumBacktracking

Generate Parentheses

## Problem

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

Examples

Input
n = 3
Output
["((()))","(()())","(())()","()(())","()()()"]
All 5 valid combinations for n=3.
Input
n = 1
Output
["()"]
Only one valid pair.

Constraints

1 <= n <= 8
Python
Loading...