problem
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
1 | For example, given n = 3, a solution set is: |
approach1
深度优先搜索
1 | class Solution { |
- time:O(n!) O(2^n) 卡特兰数
- space:O(n)
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
1 | For example, given n = 3, a solution set is: |
深度优先搜索
1 | class Solution { |
Update your browser to view this website correctly. Update my browser now