三年前刷过leetcode,今天开始决定闲来无事继续刷着玩,并且把答案传一下博客~问题描述就不写了,贴一下链接吧
https://leetcode.com/problems/toeplitz-matrix/
class Solution(object):
def isToeplitzMatrix(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: bool
"""
if not matrix:
return True
m = len(matrix)
n = len(matrix[0])
for i in range(m-1):
for j in range(n-1):
if matrix[i][j]!=matrix[i+1][j+1]:
return False
return True