坐标变换

顺时针旋转矩阵

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;
    }
全部评论
不错,很清楚
点赞 回复 分享
发布于 2021-04-16 09:17

相关推荐

废物一个0offer:认真的吗二本本科找人工智能岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务