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.
- Scan indices starting from (1, 1).
- Compare with top-left neighbor.
- Print true or false.
01EXAMPLE 1
Input
[[1,2,3,4],[5,1,2,3],[9,5,1,2]]Output
trueExplanation: All diagonals are constant.
Constraints
- Simple nested loop iteration.
Matrix
JavaScriptSystem handles I/O — write your function only
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