生成有效括号
var generateParenthesis = function(n) {
if(!n) return [];
let res = [];
function dfs(subs,left,right,n){
if(left === n && right === n){
res.push(subs);
return;
}
if(left < right){
return;
}
left < n && dfs(subs+'(',left+1,right,n);
right < n && dfs(subs+')',left,right+1,n);
}
dfs('',0,0,n);
return res;
};
最后更新于