import java.util.*;
public class Solution {
//[1,2,3] //[7,4,1]
//[4,5,6] //[8,5,2]
//[7,8,9] //[9,6,3]
//[1,4,7] //[]
//[2,5,8] //[]
//[3,6,9] //[]
public int[][] rotateMatrix(int[][] mat, int n) {
if(mat == null || n == 0) return mat ;
//主对角线翻转
for(int i = 0 ; i < n ; i ++) {
for(int j = i ; j < n ; j ++) {
int t = mat[i][j] ;
mat[i][j] = mat[j][i] ;
mat[j][i] = t ;
}
}
//左右翻转
for(int i = 0 ; i < n ; i ++) {
int s = 0 , e = n - 1 ;
while(s < e) {
int t = mat[i][s] ;
mat[i][s] = mat[i][e] ;
mat[i][e] = t ;
s ++ ;
e -- ;
}
}
return mat ;
}
}