We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ea9c51 commit 0cf08f5Copy full SHA for 0cf08f5
README.md
@@ -10,6 +10,8 @@ leetcode 测试
10
11
##### 包含的内容如下
12
13
+https://leetcode.cn/problems/reshape-the-matrix/
14
+
15
https://leetcode.cn/problems/sZ59z6/
16
17
https://leetcode.cn/problems/LwUNpT/
reshape-the-matrix/index.ts
@@ -0,0 +1,10 @@
1
+export default function matrixReshape(
2
+ mat: number[][],
3
+ r: number,
4
+ c: number,
5
+): number[][] {
6
+ if (r * c !== mat.length * mat[0].length) return mat;
7
+ const arr = mat.flat();
8
9
+ return [...Array(r).keys()].map((i) => arr.slice(i * c, i * c + c));
+}
0 commit comments