https://leetcode.com/problems/toeplitz-matrix/description/
题目大意:问一个数组是不是从左上角到右下角的一条线上的数字都一样
解题思路:直接模拟
class Solution {
public boolean isToeplitzMatrix(int[][] matrix) {
int n= matrix.length;
int m= matrix[0].length;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
int x = i+1,y =j+1;
int pre = matrix[i][j];
while(x<n && y<m)
{
if(pre ==matrix[x][y]) { x++; y++; }
else return false;
}
}
}
return true;
}
}