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:
"((()))", "(()())", "(())()", "()(())", "()()()"
class Solution {
public:
vector<string> generateParenthesis(int n) {
vector<string> result;
string item;
traverse(result, item, n, n);
return result;
}
void traverse(vector<string> &res, string &item, int left, int right)......
阅读全文