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

顺时针旋转矩阵

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

using System;
using System.Collections.Generic;


class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param mat int整型二维数组 
     * @param n int整型 
     * @return int整型二维数组
     */
    public List<List<int>> rotateMatrix (List<List<int>> mat, int n) {
        List<List<int>> res = new List<List<int>>();
        for(int i = 0; i < n; i++){
            List<int> res1 = new List<int>(new int[n]); 
            res.Add(res1);
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                res[j][n - 1 - i] = mat[i][j];
            }
        }
        return res;
    }
}

全部评论

相关推荐

05-14 09:24
青岛工学院 C++
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-02 18:35
简历上把1个月实习写成了3个月,会进行背调吗?
码农索隆:一个月有一个月的实习经历,三个月有三个月的实习经历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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