the code is giving the perfect pattern but while submitting its showing wrong answer
code is
// System.out.println("enter");
Scanner scn = new Scanner(System.in);
int n= scn.nextInt();
int row=1,nsp=n,nst=1;
while(row <= n) {
for(int csp =1;csp<=nsp;csp++) {
System.out.print(" ");
}
for(int cst=1;cst<=nst;cst++) {
System.out.print("*");
}
for(int i =1;i<=3;i++) {
if(row==1||row==n) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
for(int cst=1;cst<=nst;cst++) {
System.out.print("*");
}
System.out.println();
nsp= nsp-1;
row = row +1;
}