766. Toeplitz Matrix
https://leetcode.com/problems/toeplitz-matrix/description/
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.
Now given an M x N
matrix, return True
if and only if the matrix is Toeplitz.
Example 1:
Example 2:
Note:
matrix
will be a 2D array of integers.matrix
will have a number of rows and columns in range[1, 20]
.matrix[i][j]
will be integers in range[0, 99]
.
问矩阵是否满足反对角线上的值一致。对每个元素检查是否和左上角值相同。
Last updated
Was this helpful?