Compare every cell with its top-left neighbor. If any cell differs from its diagonal predecessor, the matrix is not Toeplitz.
Here's the solution:
function isToeplitzMatrix(matrix):
m = rows, n = cols
for r in range(1, m):
for c in range(1, n):
if matrix[r][c] != matrix[r-1][c-1]:
return false
return true
time, space.