美文网首页
22. Generate Parentheses

22. Generate Parentheses

作者: xxxcoder | 来源:发表于2020-07-09 17:31 被阅读0次

key tips

search 方法

algo1

用left,right分别记录剩余可用的左、右括号数量,做深度优先遍历,遍历终止条件为left==0 && right == 0。从某一节点开始,向下扩展的条件:1)left > 0, 添加左括号; 2) left < right, 添加右括号;

相关文章

网友评论

      本文标题:22. Generate Parentheses

      本文链接:https://www.haomeiwen.com/subject/dlvscktx.html