blob: b6ab293c146912b1aac89cb3d63614971179df4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include "leetcode.h"
#include <vector>
class Solution {
public:
vector<vector<int>> transpose(vector<vector<int>> &matrix) {
int n = matrix.size(), m = matrix[0].size();
vector<vector<int>> ans(m, vector<int>(n, 0));
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
ans[j][i] = matrix[i][j];
return ans;
}
};
int main() {
Solution obj;
vector<vector<int>> matrix;
obj.transpose(matrix);
}
|