Subsets using recursion

Can you please tell mistake in my code number of subsets are correct but combinations are wrong

Hey @coderajay03

if(open<cls){

            op+=')';

        balanced_para(op,open, cls-1);

        op.pop_back();//backtrack for next condition

    } 

If this resolves your query then please mark it as resolved :slight_smile:

can u explain why pop_back i am doing (cls-1) already to decrease no. of closing brackets left

Bro there are 2 if conditions
now assume u push ‘)’ to ur string so it remains in ur string even after coming back from further recursive calls
So in next if condition same string is used with ‘)’ appended