Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is:
1 |
[ |
给定n个小括号,写一个方法生成所有可行的括号路径
分析:典型的卡特兰数问题,知道卡特兰数的实现原理,代码就比较好理解了,详细代码如下:
1 |
class { |
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is:
1 |
[ |
给定n个小括号,写一个方法生成所有可行的括号路径
分析:典型的卡特兰数问题,知道卡特兰数的实现原理,代码就比较好理解了,详细代码如下:
1 |
class { |
近期评论