Problem
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Example
given n = 3, a solution set is:
1 | [ |
Solution1
Method: Recursive Depth First Search
Time Complexity:
Space Complexity:
1 | class Solution: |
Solution2
Method: Backtracking
Time Complexity:
Space Complexity:
1 | class Solution: |
or
1 | class Solution: |