Skip to content

Latest commit

 

History

History
21 lines (19 loc) · 390 Bytes

766-toeplitz-matrix.md

File metadata and controls

21 lines (19 loc) · 390 Bytes

托普利茨矩阵

js实现

/**
 * @param {number[][]} matrix
 * @return {boolean}
 */
var isToeplitzMatrix = function(matrix) {
    var x, y, i, j;
    x = matrix.length;
    y = x ? matrix[0].length : 0;
    for (i = 1; i < x; i++) {
        for (j = 1; j < y; j++) {
            if (matrix[i][j] !== matrix[i - 1][j - 1]) return false;
        }
    }
    return true;
};