FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
LeetCode-Solutions/C++/transpose-matrix.cpp at master · Addoile/LeetCode-Solutions · GitHub
Addoile
LeetCode-Solutions
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
LeetCode-Solutions
/
C++
/
transpose-matrix.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
15 lines (14 loc) · 385 Bytes
Breadcrumbs
LeetCode-Solutions
/
C++
/
transpose-matrix.cpp
Copy path
File metadata and controls
15 lines (14 loc) · 385 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//
Time: O(r * c)
//
Space: O(1)
class
Solution
{
public:
vector<vector<
int
>>
transpose
(vector<vector<
int
>>& A) {
vector<vector<
int
>>
result
(A[
0
].
size
(), vector<
int
>(A.
size
()));
for
(
int
r =
0
; r < A.
size
(); ++r) {
for
(
int
c =
0
; c < A[
0
].
size
(); ++c) {
result[c][r] = A[r][c];
}
}
return
result;
}
};
Back
|
FazBrowse Home
|
New Git URL