feat: 2025-10-24打卡

This commit is contained in:
wu xiangkai
2025-10-24 11:28:01 +08:00
parent d0478198a9
commit 9639d043e8
8 changed files with 338 additions and 0 deletions

38
766.toeplitz-matrix.java Normal file
View File

@@ -0,0 +1,38 @@
/*
* @lc app=leetcode id=766 lang=java
*
* [766] Toeplitz Matrix
*/
// @lc code=start
class Solution {
public boolean isToeplitzMatrix(int[][] matrix) {
for(int i=0; i<matrix.length; i++) {
if(!sameElementsLTRP(matrix, i, 0)) {
return false;
}
}
for(int j = 0; j<matrix[0].length; j++) {
if(!sameElementsLTRP(matrix, 0, j)) {
return false;
}
}
return true;
}
private boolean sameElementsLTRP(int[][] matrix, int i, int j) {
int e = matrix[i][j];
boolean f = true;
while(i < matrix.length && j < matrix[0].length) {
if(matrix[i][j] != e) {
f = false;
break;
}
i++;
j++;
}
return f;
}
}
// @lc code=end