public static int[][] rotateMatrix(int[][] mat, int n) { int[][] ans = new int[n][n]; // write code here for(int j=0; j<n; j++){ for (int i=n-1; i>=0; i--){ ans[j][n-i-1]=mat[i][j]; } } return ans; }
public static int[][] rotateMatrix(int[][] mat, int n) { int[][] ans = new int[n][n]; // write code here for(int j=0; j<n; j++){ for (int i=n-1; i>=0; i--){ ans[j][n-i-1]=mat[i][j]; } } return ans; }