[leetcode]867. Transpose Matrix

1029 ワード

[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;
    }
};