题解
代码
/*** @param {number[][]} matrix* @return {boolean}*/var isToeplitzMatrix = function(matrix) {const rows = matrix.lengthconst cols = matrix[0].lengthfunction getCell(i, j) {return matrix[i][j]}function getBottomRight(i, j) {return matrix[i+1][j+1]}for (let i = 0; i < rows - 1; i++) {for (let j = 0; j < cols - 1; j++ ) {if (getCell(i, j) !== getBottomRight(i, j)) return false}}return true}
