I have made the code and it is working fine ,
You could also check it ,but when I submit it is giving me wrong answer
Something wrong in the Question
Hey @siddhant_samal
if(close <open)//keep this block above 2nd if block (only done because this is what implemented in backend and to match output lne by line)
{
output[idx]=')';
genrate(output,n,idx+1,open,close+1);
}
if(open<n)
{
output[idx]='(';
genrate(output ,n,idx+1 ,open+1 ,close);
}
If this resolves your query then please mark it as resolved
please explain the conditional statement if(close <open)
when no of closed brackets are less than open we can simply close it and move a recursive call ahead
I haven’t changed ur code just swapped the placement of if blocks