letcode:22

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

    public List<String> generateParenthesis(int n) {
List<String> res = new ArrayList<>();
gen(res, n, n, "");
return res;
} private void gen(List<String> res, int left, int right, String str) {
if (left == 0 && right == 0) {
res.add(str);
return;
}
if (left > 0) {
gen(res, left - 1, right, str + "(");
}
if(right > left){
gen(res, left, right - 1,str + ")");
}
}

最新文章

  1. 魔法禁书目录2:回家(codevs 3024)
  2. windowsapi
  3. 汇编学习(六)&mdash;&mdash;代码转换程序
  4. [SAP ABAP开发技术总结]客户端文本文件、Excel文件上传下载
  5. ASP.NET Eval四种绑定方式
  6. oracle11g安装成功
  7. Atom编辑器入门到精通(三) 文本编辑基础
  8. phpquery笔记
  9. Java Keyword -- super
  10. SDI接口
  11. Socket在手机上的应用
  12. ruby中如何调用与局部变量同名的私有方法
  13. 在阿里云开源镜像站中下载centOS7
  14. pip3 升级失败的解决方法!亲测有效
  15. 用vi编辑文件
  16. Swagger2使用参考
  17. String s = new String(&quot;xyz&quot;);产生了几个对象?
  18. [Leetcode 55]跳格子JumpGame
  19. Java网络通信 TCP网络,ServerSocket类
  20. Swoole 结合TP5创建http服务

热门文章

  1. LeetCode.944-删除列保证排序(Delete Columns to Make Sorted)
  2. 20个python项目--图片转字符画
  3. 【miscellaneous】星光级超低照度摄像机技术分析
  4. c语言l博客作业11
  5. 插入排序--python
  6. [Python3] 032 常用模块 random
  7. WorkStation Linux 客户端 虚拟机的使用过程
  8. Spark中的术语图解总结
  9. C++中的异常处理(上)
  10. [Codeforces 1245D] Shichikuji and Power Grid (最小生成树)