nc18

class Solution {
public:
    vector<vector<int> > rotateMatrix(vector<vector<int> > mat, int n) {
        vector<vector<int> > ans(n);
        for(int i = 0 ; i < n ; i++)
        {
            ans[i].resize(n);
        }
        for(int x = 0 ; x < n ;x++)
        {
            for(int y = 0 ; y < n ; y++)
            {
                ans[y][n-1-x] = mat[x][y];
            }
        }
        return ans;
    }
};
全部评论

相关推荐

2 2 评论
分享
牛客网
牛客企业服务