题解 | #java实现#
顺时针旋转矩阵
http://www.nowcoder.com/practice/2e95333fbdd4451395066957e24909cc
import java.util.*;
public class Solution {
public int[][] rotateMatrix(int[][] mat, int n) {
// write code here
int row = mat.length;
int col = mat[0].length;
int[][] res = new int[mat.length][mat[0].length];
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
res[i][j] = mat[row - 1 - j][i];
}
}
return res;
}
}
阿里云工作强度 612人发布