helper( vector< string> & ans, int n, int i, int j, string s) {
if ( i > n || j > n || j > i) {
return ;
}
if ( i == n && j == n) {
ans.push_back ( s) ;
return ;
}
helper( ans, n, i+ 1 , j, s+ "(" ) ;
helper( ans, n, i, j+ 1 , s+ ")" ) ;
}
vector< string> generateParenthesis( int n) {
vector< string> ans;
helper( ans, n, 0 , 0 , "" ) ;
return ans;
}
CWhlbHBlcih2ZWN0b3I8c3RyaW5nPiAmYW5zLCBpbnQgbiwgaW50IGksIGludCBqLCBzdHJpbmcgcykgewogICAgICAgIGlmIChpID4gbiB8fCBqID4gbiB8fCBqID4gaSkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIGlmIChpID09IG4gJiYgaiA9PSBuKSB7CiAgICAgICAgICAgIGFucy5wdXNoX2JhY2socyk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaGVscGVyKGFucywgbiwgaSsxLCBqLCBzKyIoIik7CiAgICAgICAgaGVscGVyKGFucywgbiwgaSwgaisxLCBzKyIpIik7CiAgICB9CiAgICB2ZWN0b3I8c3RyaW5nPiBnZW5lcmF0ZVBhcmVudGhlc2lzKGludCBuKSB7CiAgICAgICAgdmVjdG9yPHN0cmluZz4gYW5zOwogICAgICAgIGhlbHBlcihhbnMsIG4sIDAsIDAsICIiKTsKICAgICAgICByZXR1cm4gYW5zOwogICAgfQ==
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