class Solution:
def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool:
m, n = len(matrix), len(matrix[0])
def is_same(x,y):
num=matrix[x][y]
while 0<=x<m and 0<=y<n:
if matrix[x][y]!=num:return False
x+=1
y+=1
return True
for i in range(m):
if not is_same(i,0):return False
for i in range(n):
if not is_same(0,i):return False
return True
766. Toeplitz Matrix
最新推荐文章于 2025-09-09 20:07:09 发布