quesrion–>
code–>
not passing all testcases
quesrion–>
code–>
not passing all testcases
please see the corrected code:
if you have any doubt you can ask here:
Happy Learning!!
bro why are doing close==n in the base case;
in string are the null terminater taken care by itself?
class Solution {
public:
void func(string ans,int i, int n,int open ,int close,vector<string> &v){
if(i==2*n){
v.push_back(ans);
return ;
}
if(open<n){
func(ans+'(',i+1,n,open+1,close,v);
}
if(close<open){
// a[i]=')';
func(ans+')',i+1,n,open,close+1,v);
}
}
vector<string> generateParenthesis(int n) {
vector <string> v;
string ans;
func(ans,0,n,0,0,v);
return v;
}
};
it got submitted when i used string thanks @tusharaggarwal272
@sheikhhaji18 if you feel that your doubt is cleared then plesse mark this doubt as resolved.
Happy Learning!!
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.