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

We'll now take you through what you need to know.

How do I use this guide?

Access all course materials today

The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.

Returning members can login to stop seeing this.