Medium

Quiz

#22 Generate Parentheses

APPROACH

Produce every possible string of well-formed, correctly nested parentheses using exactly n pairs.

Example 1:

Input: n = 3
Output: ["((()))","(()())","(())()","()(())","()()()"]

Example 2:

Input: n = 1
Output: ["()"]
1 of 4
1:00

What is the optimal approach for this problem?