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.
就是说从左上到右下斜对角的元素都相等,判断一下就行
class Solution(object): def isToeplitzMatrix(self, matrix): """ :type matrix: List[List[int]] :rtype: bool """ for i in range(1, len(matrix), 1): for j in range(1, len(matrix[0]), 1): if matrix[i][j] != matrix[i - 1][j - 1]: return False return True