You are given an integer n representing the number of pairs of parentheses.
Your task is to generate all combinations of well-formed (valid) parentheses using exactly n pairs.
Note that:
( matched with a corresponding closing parenthesis ).Return all possible valid combinations. The order of the combinations in the result does not matter.
3
["((()))", "(()())", "(())()", "()(())", "()()()"]
There are exactly 5 valid combinations using 3 pairs of parentheses.
1
["()"]
With only 1 pair, there is exactly one valid combination.
2
["(())", "()()"]
With 2 pairs, there are exactly 2 valid combinations.
3
["((()))", "(()())", "(())()", "()(())", "()()()"]