博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LeetCode – Refresh – Generate Parentheses
阅读量:7114 次
发布时间:2019-06-28

本文共 714 字,大约阅读时间需要 2 分钟。

Nothing fancy, just use recursive.

1 class Solution { 2 public: 3     void getP(vector
&result, string current, int left, int right) { 4 if (left == 0 && right == 0) { 5 result.push_back(current); 6 return; 7 } 8 if (left > 0) { 9 getP(result, current + '(', left - 1, right + 1);10 }11 if (right > 0) {12 getP(result, current + ')', left, right - 1);13 }14 }15 vector
generateParenthesis(int n) {16 vector
result;17 getP(result, "", n, 0);18 return result;19 }20 };

 

转载于:https://www.cnblogs.com/shuashuashua/p/4352212.html

你可能感兴趣的文章
vue按需引入element Transfer 穿梭框
查看>>
Facebook 2018 年度开源回顾:新增开源项目 153 个
查看>>
JDBC的数据类型
查看>>
「镁客·请讲」Ayla米歇尔·马埃索:在物联网,我们要做一个“中心环节”
查看>>
PiFlow v0.5 发布:大数据流水线系统
查看>>
iOS__上传应用到AppStore出现Authenticating with the iTunes store
查看>>
mac下设置eclipse自动提示
查看>>
IntelliJ IDEA中日志分类显示设置
查看>>
数据结构思维 第十六章 布尔搜索
查看>>
独家|从满天飞舞到逐步落地,自动驾驶好消息只会越来越多
查看>>
如何找到后台运行的隐藏程序
查看>>
多维防护:虚拟化安全挑战的破解之道
查看>>
从羽泉到智能硬件,离婚后的胡海泉走过了一条什么样的道路?
查看>>
VR训练营第一期:聊聊全景拍摄和直播那点事
查看>>
Ubuntu 16.04下ssh启用root登录
查看>>
2016中国大数据大会暨大数据年度盛典将于12月20日在京举办
查看>>
双11大幕拉开,菜鸟智能机器人也将测试运行
查看>>
Mac OS 10.12使用SecureCRT 8.1.4无法保存密码的问题解决
查看>>
windbg调试实例(4)--句柄泄露
查看>>
关于directX最近的学习方案
查看>>