File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,12 @@ module.exports = {
15
15
language : "cpp" ,
16
16
text : `
17
17
vector<vector<int>> rotate(vector<vector<int>> &mat) {
18
- int n = mat.size();
19
- vector<vector<int>> ans(n, vector<int>(n));
20
- for (int i = 0; i < n; ++i)
18
+ int m = mat.size();
19
+ int n = mat[0].size()
20
+ vector<vector<int>> ans(n, vector<int>(m));
21
+ for (int i = 0; i < m; ++i)
21
22
for (int j = 0; j < n; ++j)
22
- ans[j][n - 1 - i] = mat[i][j];
23
+ ans[j][m - 1 - i] = mat[i][j];
23
24
return ans;
24
25
}
25
26
` ,
@@ -28,11 +29,11 @@ vector<vector<int>> rotate(vector<vector<int>> &mat) {
28
29
language : "py" ,
29
30
text : `
30
31
def rotate(mat):
31
- n = len(mat)
32
- ans = [[0] * n for _ in range(n)]
33
- for i in range(n ):
32
+ m, n = len(mat), len(mat[0] )
33
+ ans = [[0] * m for _ in range(n)]
34
+ for i in range(m ):
34
35
for j in range(n):
35
- ans[j][n - i - 1] = mat[i][j]
36
+ ans[j][m - i - 1] = mat[i][j]
36
37
return ans
37
38
` ,
38
39
} ,
You can’t perform that action at this time.
0 commit comments