Skip to content

Practice Toeplitz Matrix

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#766
LeetCode Problem

Toeplitz Matrix

Problem Statement

Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.

Source: Toeplitz Matrix on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
matrix = [[1,2,3,4],[5,1,2,3],[9,5,1,2]]
Output
true

# Example 2

Input
matrix = [[1,2],[2,2]]
Output
false

Constraints

m == matrix.length
n == matrix[i].length
1 <= m, n <= 20
0 <= matrix[i][j] <= 99

Related LeetCode Problems

Practice more problems similar to Toeplitz Matrix.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.