Generate Parentheses
来源:互联网 发布:视频加特效软件 编辑:程序博客网 时间:2024/09/21 09:18
public class Solution { public List<String> generateParenthesis(int n) { List<String> res = new LinkedList<>(); if (n < 1) { return res; } helper(res, "", n, n); return res; } private void helper(List<String> res, String str, int leftCount, int rightCount) { if (leftCount == 0 && rightCount == 0) { res.add(str); return; } if (leftCount > 0) { helper(res, str + "(", leftCount - 1, rightCount); } if (rightCount > 0 && rightCount > leftCount) { helper(res, str + ")", leftCount, rightCount - 1); } }}
0 0
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- Generate Parentheses
- ST表与二分 (CodeForces 689D-Friends and Subsequences)
- codeforces 701C They Are Everywhere(尺取法)
- 利用无线网卡建立个人wifi hotspot
- POJ1328-Radar Installation
- 关于在MySQL中实现upsert操作
- Generate Parentheses
- Singleton Pattern
- 基于SQL语句的断码查询
- 从零开始学习设计模式——简单工厂模式
- ST表的应用(poj--3368)
- Factory Pattern
- GAME TIMERS: ISSUES AND SOLUTIONS.
- Swing线程之SwingUtilities.invokeLater解释
- Swap Nodes in Pairs