766. Toeplitz Matrix
https://leetcode.com/problems/toeplitz-matrix/
Python
from collections import defaultdict
class Solution:
def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool:
m, n = len(matrix), len(matrix[0])
mapper = defaultdict(set)
for row in range(m):
for col in range(n):
mapper[row-col].add(matrix[row][col])
return all([len(items) == 1 for items in mapper.values()])