1. 题目原址
https://leetcode.com/problems/toeplitz-matrix/
2. 题目描述
3. 题目大意
给定一个二维数组,判断数组中的斜着的每一列是否相等
4. 解题思路
签到题
5. AC代码
class Solution {
public boolean isToeplitzMatrix(int[][] matrix) {
if(matrix == null || matrix[0].length == 0) return true;
for(int i = 0; i < matrix.length; i++) {
for(int j = 0; j < matrix[0].length; j++) {
int m = i, n = j, temp = matrix[i][j];
while(m < matrix.length && n < matrix[0].length) {
if(temp != matrix[m][n])
return false;
else {
m ++;
n ++;
}
}
}
}
return true;
}
}