Generate parentheses

THE CODE IS WORKING FINE IN MY LOCAL MACHINE BUT IT JUST DON’T WORK ON THE ONLINE IDE

You have to pass 2n in the recursive function because your final string will be of size 2n.
I modified your code a bit. Check it and tell me if you are able to understand it -