Hi, my code works fine when I’ve checked, and also the samp,e test case passes but the remaining test cases are failing, can you please let me know what’s wrong with the code?
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int [][] arr = new int [n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int arrVal = sc.nextInt();
arr[i][j] = arrVal;
}
}
int count = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(arr[i][count]+", ");
if((i+2) % 2 == 0) {
if(count < n-1)
count ++;
} else {
if(count > 0) {
count–;
}
}
}
}
System.out.print(“END”);