import java.util.Scanner;
public class RotateBy90Degree {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
int[][] arr = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
arr[i][j] = s.nextInt();
}
}
int[][] arr1 = new int[m][n];
s.close();
int row=0, col=n-1;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
if(row>=0 && col>=0){
arr1[row][col]=arr[j][i];
}
if(col<=0){
row++;
col=n-1;
} else {
col--;
}
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
System.out.print(arr1[i][j]+" ");
}
System.out.println();
}
}
}
This is Java Code I don't know why when I am running this on VScode I am not getting any error, my output is perfectly good but If I run this code on a website called "pepcoding" it showing me this error like this
Exception in thread "main" java.util.NoSuchElementException
at java.base/java.util.Scanner.throwFor(Scanner.java:937)
at java.base/java.util.Scanner.next(Scanner.java:1594)
at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
at Main.main(Main.java:11)
can somebody confirm that it is my error in the program or the website is not correct