Shawn's Blog

  • Home
  • Tags
  • Categories
  • Archives
  • Search
  • Table of Contents
  • Overview

Shawn

若有恒,何必三更眠五更起;最无益,莫过一日曝十日寒。
392 posts
13 categories
114 tags

LeetCode 867. Transpose Matrix

Posted on 2021-02-25 Edited on 2024-11-24 In LeetCode
1
2
3
4
5
6
7
8
9
10
11
class Solution {
public:
vector<vector<int>> transpose(vector<vector<int>>& matrix) {
int R = matrix.size(), C = matrix[0].size();
vector<vector<int>> ans(C, vector<int>(R));
for (int r = 0; r < R; ++r)
for (int c = 0; c < C; ++c)
ans[c][r] = matrix[r][c];
return ans;
}
};
# Array
LeetCode 832. Flipping an Image
LeetCode 1178. Number of Valid Words for Each Puzzle
© 2024 Shawn
Powered by Hexo & NexT.Mist
0%