题解 | #顺时针旋转矩阵#

顺时针旋转矩阵

http://www.nowcoder.com/practice/2e95333fbdd4451395066957e24909cc


public class Solution {
    public int[][] rotateMatrix(int[][] mat, int n) {
        // write code here
        //mat[i][j]旋转到mat[j][n-i-1]的位置
        int[][] temp = new int[n][n];
        for(int i = 0;i<n;i++){
            for(int j = 0;j< n;j++){
                temp[j][n-1-i] = mat[i][j];
            }
        }
        return temp;
    }
}
全部评论

相关推荐

一天代码十万三:实习东西太少了,而且体现不出你业务,3个月不可能就这点产出吧,建议实习多写点,玩具项目面试官都不感兴趣的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务