Mark As Completed Discussion

Good morning! Here's our prompt for today.

A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same elements.

Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false.

Question

For example, consider the matrices above. The first matrix has all its diagonals filled with the same elements, whereas the second matrix has only two diagonals with the same elements. Having even a single diagonal with different elements would not make the matrix, a Toeplitz matrix.

Constraints

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

Try to solve this here or in Interactive Mode.

How do I practice this challenge?

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Here's how we would solve this problem...

How do I use this guide?