MANMOHAN LOVES PATTERNS- II , my code is giving correct output but it is not submitting

This is the code

Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
if(n<=1000){
int nst=1,nsp=1;
for(int row=1;row<=n/2;row++)
{
int cst=1;
while(cst<=nst)
{
System.out.print(“1”);
cst=cst+1;
}
System.out.println();
nst=nst+1;
}
for(int row=(n/2+1); row<=n; row++)
{
System.out.print(row-1);
int csp=1;
while(csp<=nsp)
{
System.out.print(“0”);
csp=csp+1;
}
nsp=nsp+1;
System.out.print(row-1);
System.out.println();
}
}

For input 1, output should be 1, your code shows 000

For n>=1, are the outputs coming correct??

Sir can you please help me by correcting me where my code is going wrong??

just hardcode it for n=1 if you are not able to correct, Your output is fine for n>1

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.

for the input 7
ur code o/p:

1
11
111
1111
404
5005
60006
700007

ur code is wrong
u are printing 1 for first half row

this prblm is same as



just print row no. in the first and last column
and for the rest print 0

hope this will help u
pls rate my work

for the input 7
ur code o/p:

1
11
111
1111
404
5005
60006
700007

ur code is wrong
u are printing 1 for first half row

this prblm is same as

just print row no. in the first and last column
and for the rest print 0

hope this will help u
pls rate my work

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.