leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0867.cpp (388B)


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