//Print the spiral order matrix as output for a given matrix of numbers. package Array; import java.util.*; public class SpiralOrderMatrix { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int matrix[][] = new int[n][m]; for(int i=0; i=colStart; col--) { System.out.print(matrix[rowEnd][col] + " "); } rowEnd--; //4 for(int row=rowEnd; row>=rowStart; row--) { System.out.print(matrix[row][colStart] + " "); } colStart++; System.out.println(); } } }