"""
766
easy
toeplitz matrix
"""


from typing import List


class Solution:
    def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool:

        m = len(matrix)
        n = len(matrix[0])

        for j in range(n):
            curr_val = matrix[0][j]
            for i in range(m):
                if j + i > n - 1:
                    continue
                else:
                    if matrix[i][j+i] != curr_val:
                        return False

        for i in range(m):
            curr_val = matrix[i][0]
            for j in range(n):
                if i + j > m - 1:
                    continue
                else:
                    if matrix[i+j][j] != curr_val:
                        return False

        return True


matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
matrix2 = [[1,2],[2,2]]
sol = Solution()
print(sol.isToeplitzMatrix(matrix2))

"""
766
easy
toeplitz matrix
"""


from typing import List


class Solution:
    def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool:

        m = len(matrix)
        n = len(matrix[0])

        for j in range(n):
            curr_val = matrix[0][j]
            for i in range(m):
                if j + i > n - 1:
                    continue
                else:
                    if matrix[i][j+i] != curr_val:
                        return False

        for i in range(m):
            curr_val = matrix[i][0]
            for j in range(n):
                if i + j > m - 1:
                    continue
                else:
                    if matrix[i+j][j] != curr_val:
                        return False

        return True


matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
matrix2 = [[1,2],[2,2]]
sol = Solution()
print(sol.isToeplitzMatrix(matrix2))

766 easy toeplitz matrix