leetcode867 C++ 32ms 转置矩阵
class Solution {
public:
vector<vector<int>> transpose(vector<vector<int>>& A) {
vector<vector<int>> res;
if(A.empty() || A[0].empty()){
return res;
}
int h = A.size();
int w = A[0].size();
vector<int> row;
for(int ww=0;ww <w; ww++){
row.clear();
for(int hh=0; hh<h;hh++){
row.push_back(A[hh][ww]);
}
res.push_back(row);
}
return res;
}
};