[leetcode]867. Transpose Matrix

[leetcode]867. Transpose Matrix


Analysis

ummmm~—— [ummmm~]

Given a matrix A, return the transpose of A.
The transpose of a matrix is the matrix flipped over it’s main diagonal, switching the row and column indices of the matrix.
矩阵转置~

Implement

class Solution {
public:
    vector> transpose(vector>& A) {
        vector> res;
        int len1 = A.size();
        int len2 = A[0].size();
        res.resize(len2);
        for(int i=0; ifor(int i=0; ifor(int j=0; jreturn res;
    }
};

你可能感兴趣的:(LeetCode)