顺时针旋转90度,mat[i][j]的坐标变为mat[j][n - i - 1] ,遍历即可

import java.util.*;

public class Solution {
public int[][] rotateMatrix(int[][] mat, int n) {

    
    int[][] newMat = new int[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            newMat[j][n - i - 1] = mat[i][j];
        }
    }
    return newMat;


    // write code here
}

}