68. Generate Parentheses

Return all well-formed strings made of n pairs of parentheses, in any order.

Example 1

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

Example 2

Input: n = 1
Output: ["()"]
Hint 1

Only add “(” while you have some left, and only add “)” when it closes an open one.

BacktrackingString