Toeplitz Matrix

EasyAcc. 96.2%
+15 XP 5

Constant Diagonals

A matrix is Toeplitz if matrix[i][j] === matrix[i-1][j-1] for all indices.

The Assignment

Your function receives matrix.

  1. Scan indices starting from (1, 1).
  2. Compare with top-left neighbor.
  3. Print true or false.

01EXAMPLE 1

Input[[1,2,3,4],[5,1,2,3],[9,5,1,2]]
Outputtrue

Explanation: All diagonals are constant.

Constraints

  • Simple nested loop iteration.
Matrix
JavaScript
Loading...
1 Hidden

Input Arguments

matrix[[1,2,3,4],[5,1,2,3],[9,5,1,2]]

Expected Output

true

Click RUN to test your solution