Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Input: n = 3
Output: ["((()))","(()())","(())()","()(())","()()()"]
Topics: stack, backtracking
Asked by: Amazon, Google, Meta, Microsoft
Time complexity: O(4^n / sqrt(n)). Space complexity: O(n) recursion depth.