mirror of https://github.com/doocs/leetcode.git
14 lines
370 B
C++
14 lines
370 B
C++
class Solution {
|
|
public:
|
|
vector<vector<int>> transpose(vector<vector<int>>& matrix) {
|
|
int m = matrix.size(), n = matrix[0].size();
|
|
vector<vector<int>> ans(n, vector<int>(m));
|
|
for (int i = 0; i < n; ++i) {
|
|
for (int j = 0; j < m; ++j) {
|
|
ans[i][j] = matrix[j][i];
|
|
}
|
|
}
|
|
return ans;
|
|
}
|
|
};
|