766 Teoplitz Matrix
Last updated
Last updated
A matrix is_Toeplitz_if every diagonal from top-left to bottom-right has the same element.
Now given anM x N
matrix, return True
if and only if the matrix isToeplitz.
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]
.
Follow up:
What if the matrix is stored on disk, and the memory is limited such that you can only load at most one row of the matrix into the memory at once?
What if the matrix is so large that you can only load up a partial row into the memory at once?
判断输入的是否一个合法的Tmatrix,第一个follow up只想到load第一行,然后把最后一个去掉,把第二行的第二个load进来,如此类推地比较。第二个follow up感觉要overlap一些,然后一个个三角形覆盖着做。