思路:
判断每个值是否等于左上角的值
代码:
/**
* @param {number[][]} matrix
* @return {boolean}
*/
var isToeplitzMatrix = function(matrix) {
if(matrix.length<2) return true;
let ret = true;
for(let row = 0; row < matrix.length; row ++){
for(let col = 0; col< matrix[row].length; col++){
if(row-1 >= 0 && col - 1 >= 0){
if(matrix[row][col] !== matrix[row-1][col-1]){
ret = false
}
}
}
}
return ret;
};