利用数学中的旋转性质,可以求出旋转后的坐标,对应到数组中即可。代码如下: public class Solution { public int[][] rotateMatrix(int[][] mat, int n) { // write code here int[][] res = new int[n][n]; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ res[i][j] = mat[n-j-1][i]; } } return res; } }