import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int nst=1;
int nsp=2n-3;
int row=1;
while(row<=n){
for(int cst=1;cst<=nst;cst++){
System.out.print(cst+" “);
}
for(int csp=1;csp<=nsp;csp++){
System.out.print(” “);
}
int cst=1;
if(row==n){
cst=2;
}
for(;cst<=nst;cst++){
System.out.print(nst+” ");
}
System.out.println();
nst++;
nsp=nsp-2;
row++;
sc.close();
}
}
}
in question pattern mountain i am getting wrong output
1 1
1 2 2 1
1 2 3 3 2 1
1 2 3 4 3 2 1 but i need this output
and wrong output is
1 1
1 2 1 2
1 2 3 1 2 3
1 2 3 4 2 3 4