Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
def generateParenthesis(self, n: int) -> List[str]:
ans = []
def backtrack(s, left, right):
if left == right == n:
ans.append(s)
return
if left < n:
backtrack(s + '(', left + 1, right)
if left > right:
backtrack(s + ')', left, right + 1)
backtrack('', 0, 0)
return ans