1 2 3 4 5 6 7 8 9 10 11 12 13 14
| class Solution { public: vector<vector<int>> transpose(vector<vector<int>>& matrix) { int n=matrix.size(); int m=matrix[0].size(); vector<vector<int>> res(m, vector<int>(n, 0)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { res[j][i] = matrix[i][j]; } } return res; } };
|