```
void help(vector<string>& parentheses, string cur, int leftCount, int n) {
if (leftCount > cur.size() - leftCount) {
help(parentheses, cur + ")", leftCount, n);
}
if (leftCount < n) {
help(parentheses, cur + "(", leftCount + 1, n);
}
if (cur.size() == n * 2) {
parentheses.push_back(cur);
}
}
vector<string> generateParenthesis(int n) {
vector<string> parentheses;
help(parentheses, "", 0, n);
return parentheses;
}
```