LeetCode 766 Toeplitz Matrix

LeetCode 766 Toeplitz Matrix Problem

Download Code
class Solution(object):
    def isToeplitzMatrix(self, matrix):
        """
        :type matrix: List[List[int]]
        :rtype: bool
        """
        # Actually, we don't need to check the last row and column
        for r in range(len(matrix) - 1):
            for c in range(len(matrix[0]) - 1):
                if matrix[r][c] != matrix[r + 1][c + 1]:
                    return False
        return True
Download Toeplitz Matrix.py

List of all Toeplitz Matrix problems

Leetcode 766 Toeplitz Matrix problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.

Feedback is the most important part of any website.

If you have any query, suggestion or feedback, Please feel free to contact us.