坐标变换
顺时针旋转矩阵
http://www.nowcoder.com/questionTerminal/2e95333fbdd4451395066957e24909cc
public int[][] rotateMatrix(int[][] mat, int n) {
// write code here
if (mat == null){
return null;
}
if (n <= 1){
return mat;
}
int[][] res = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
res[j][n-i-1] = mat[i][j];
}
}
return res;
}
查看7道真题和解析