###### Leetcode#22 Generate Parentheses

Difficulty: Medium

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

For example, given n = 3, a solution set is:

"((()))", "(()())", "(())()", "()(())", "()()()"

void gen(int le, int ri, string s, vector<string>& ans){
if(le==0&&ri==0)
ans.push_back(s);
if(le>0){
gen(le-1,ri,s+'(',ans);
}
if(ri>le&&ri>0){
gen(le,ri-1,s+')',ans);
}

}

vector<string> generateParenthesis(int n) {
vector<string> ans;
string s;
gen(n,n,s,ans);
return ans;
}

#### Leetcode#22||Generate Parentheses

2015-08-12 15:59:42

#### LeetCode#22* Generate Parentheses

2017-07-18 11:45:10

#### LeetCode 22：Generate Parentheses的递归，回溯两种解法

2015-08-24 11:29:56

#### LeetCode 22 — Generate Parentheses（C++ Java Python）

2014-04-17 11:11:41

#### LeetCode 22 Generate Parentheses (C,C++,Java,Python)

2015-05-10 21:11:15

#### leetcode之 Generate Parentheses

2013-10-26 23:19:18

#### LeetCode Generate Parentheses 深度分析理解

2013-11-26 08:05:53

#### LeetCode（22）Generate Parentheses

2015-09-26 19:57:28

#### 【LeetCode】Generate Parentheses 解题报告

2014-10-16 15:26:03

#### leetCode 22.Generate Parentheses (生成括号) 解题思路和方法

2015-07-06 22:11:08

## 不良信息举报

Leetcode#22 Generate Parentheses