时间复杂度 时间复杂度(O(2^n))
class Solution {
public:
vector<string> generateParenthesis(int n) {
vector<string> vec;
getParenthesis(n,n,"",vec);
return vec;
}
void getParenthesis(int n1,int n2,string str,vector<string> &vec){
if(n1==0&&n2==0)vec.push_back(str);
if(n1>0)getParenthesis(n1-1,n2,str+"(",vec);
if(n2>n1&&n2>0)getParenthesis(n1,n2-1,str+")",vec);
}
};