Skip to content

Commit 812a019

Browse files
committed
https://leetcode.cn/problems/toeplitz-matrix/
1 parent 487d1fa commit 812a019

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Step 2. Add the dependency
4545

4646
<summary>展开查看</summary>
4747

48+
https://leetcode.cn/problems/toeplitz-matrix/
49+
4850
https://leetcode.cn/problems/transpose-matrix/
4951

5052
https://leetcode.cn/problems/divide-array-in-sets-of-k-consecutive-numbers

toeplitz-matrix/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function isToeplitzMatrix(matrix: number[][]): boolean {
2+
return matrix.every((a, i) =>
3+
a.every((v, j) => {
4+
if (typeof matrix[i + 1]?.[j + 1] === "undefined") return true;
5+
6+
return matrix[i + 1]?.[j + 1] === v;
7+
})
8+
);
9+
}
10+
export default isToeplitzMatrix;

0 commit comments

Comments
 (0)