while compling output is perfectly coming but when i submitted the code it does’nt pass any test case show 0
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();
//declare the array
int [][] arr = new int[M][N];
for(int i=0;i<=arr.length-1;i++){
arr[i] = new int[N];
for(int j=0;j<=arr.length-1;j++)
{
arr[i][j] = sc.nextInt();
}
System.out.println();
}
WaveColumn(arr);
}
public static void WaveColumn(int [][] arr)
{
for(int j=0; j<=arr.length-1;j++)
{
if(j%2==0)
{
for(int i=0; i<=arr[j].length-1;i++)
{
System.out.print(arr[i][j]+ ", ");
}
}
else
{
for(int i=arr[j].length-1;i>=0;i--)
{
System.out.print(arr[i][j]+ ", ");
}
}
}
System.out.print("END");
}
}
this is my code