Skip to content

Latest commit

 

History

History
19 lines (18 loc) · 493 Bytes

766_托普利茨矩阵.md

File metadata and controls

19 lines (18 loc) · 493 Bytes

##766 托普利茨矩阵

class Solution {
    public boolean isToeplitzMatrix(int[][] matrix) {
        int rows = matrix.length;
        int cols = matrix[0].length;
        for(int i = 0; i< rows - 1; i++){
            for(int j = 0; j< cols - 1; j++){
                if(matrix[i][j] != matrix[i + 1][j + 1]){
                    return false;
                }
            }
        }
        return true;
    }
}

注意循环时ij的区间取值