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
.

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?
xxxxxxxxxx
54
var assert = require('assert');
​
function is_toeplitz_matrix(matrix) {
//fill in
return matrix
}
​
try {
assert.equal(is_toeplitz_matrix([
[1, 2, 3, 4],
[5, 1, 2, 3],
[9, 5, 1, 2]
]), true);
​
console.log('PASSED: ' + "is_toeplitz_matrix([[1,2,3,4],[5,1,2,3],[9,5,1,2]]) should return `true`");
} catch (err) {
console.log(err);
}
​
try {
assert.equal(is_toeplitz_matrix([
[1, 2, 3],
[4, 1, 2],
[5, 4, 1]
]), true);
​
console.log('PASSED: ' + "is_toeplitz_matrix([[1,2,3],[4,1,2],[5,4,1]]) should return `true`");
} catch (err) {
console.log(err);
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?