Skip to content

Commit d494ce8

Browse files
committed
Runtime: 1 ms (Top 90.50%) | Memory: 50.7 MB (Top 48.08%)
1 parent a33ae41 commit d494ce8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
// Runtime: 1 ms (Top 90.50%) | Memory: 50.7 MB (Top 48.08%)
12
class Solution {
23
public int[][] matrixReshape(int[][] mat, int r, int c) {
3-
4+
45
if (r * c != mat.length * mat[0].length) {
56
return mat;
67
}
7-
8+
89
int[][] ans = new int[r][c];
9-
10+
1011
int i = 0;
1112
int j = 0;
12-
13+
1314
for(int k = 0; k < mat.length; k++) {
1415
for(int l = 0; l < mat[0].length; l++) {
1516
if (j == c) {
@@ -21,4 +22,4 @@ public int[][] matrixReshape(int[][] mat, int r, int c) {
2122
}
2223
return ans;
2324
}
24-
}
25+
}

0 commit comments

Comments
 (0)