import java.util.*;
public class Solution { public int[][] rotateMatrix(int[][] mat, int n) { int[][] result = new int[n][n]; for (int j = 0; j < n; j++) { int[] array = new int[n]; int k = 0; for (int i = n - 1; i >= 0; i--) { array[k++] = mat[i][j]; } result[j] = array; } return result; } }