Test cases not run

check logic

The size of your final string will be 2n. So in your recursive function, for the base case, check only if ans.size() == 2n.
Now you have to generate balanced parenthesis, so for adding a closed bracket, you have to check if(closed < open). And for adding an open bracket, you have to check if (open < n).

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.