import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int m=sc.nextInt();
int n=sc.nextInt();
int i,j;
int count=0;
int count1=0;
int a[][]=new int[m][n];
int b[]=new int[100];
Arrays.fill(b,100);
int top=0;int left=0;int right=n-1;int bottom=m-1;
for(i=0;i<m;i++){
for( j=0;j<n;j++){
a[i][j]=sc.nextInt();
}
}
for(count1=1;count1<=m/2&&count1<=n/2;count1++){
for(i=top;i<=bottom;i++){
b[count++]=a[i][left];
}
for(i=top;i<=bottom;i++){
b[count++]=a[i][left];
}
for(i=left+1;i<=right;i++){
b[count++]=a[bottom][i];
}
for(i=bottom-1;i>=top;i–){
b[count++]=a[i][right];
}
for(i=right-1;i>left;i–){
b[count++]=a[top][i];
}
top++;
bottom–;
right–;
left++;
}
if(top==bottom && left==right){
b[count++]=a[top][left];
}
else if(top<bottom)
{
for(i=top;i<=bottom;i++){
b[count++]=a[i][left];
}
}
else if(left<right){
for(i=left;i<=right;i++)
{
b[count]=a[top][i];
}
}
for( i=0;i<mn;i++){
System.out.print(b[i]+", ");
}
System.out.print(“END”);
}
}
plz help where i went wrong…i done max but last 3 digits are not getting as required