fork download
  1. helper(vector<string> &ans, int n, int i, int j, string s) {
  2. if (i > n || j > n || j > i) {
  3. return;
  4. }
  5. if (i == n && j == n) {
  6. ans.push_back(s);
  7. return;
  8. }
  9. helper(ans, n, i+1, j, s+"(");
  10. helper(ans, n, i, j+1, s+")");
  11. }
  12. vector<string> generateParenthesis(int n) {
  13. vector<string> ans;
  14. helper(ans, n, 0, 0, "");
  15. return ans;
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:8: error: expected constructor, destructor, or type conversion before ‘(’ token
  helper(vector<string> &ans, int n, int i, int j, string s) {
        ^
prog.cpp:12:5: error: ‘vector’ does not name a type
     vector<string> generateParenthesis(int n) {
     ^~~~~~
stdout
Standard output is empty