import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
char out[]=new char[100];
generate(0,0,0,n,out);
}
static void generate(int opn,int clo,int i,int n,char out[]){
if(i==2n){
for(int t=0;t<2*n;t++){
System.out.print(out[t]);
}
System.out.println();
}
if(opn<n){
out[i]=β(β;
generate(opn+1,clo,i+1,n,out);
}
if(clo<opn){
out[i]=β)β;
generate(opn,clo+1,i+1,n,out);
}
}
}
This code couldn't pass testcase ......generate parenthesis problem
i m not able to submitt codeβ¦but it giving correct output for custom input
I`ll help u know about the problem
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.