LeetCode 3142 判断矩阵是否满足条件
方法1:模拟
class Solution {
public boolean satisfiesConditions(int[][] grid) {
int n = grid.length, m = grid[0].length;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (i < n - 1 && grid[i][j] != grid[i + 1][j])
return false;
if (j < m - 1 && grid[i][j] == grid[i][j + 1])
return false;
}
}
return true;
}
}
标签:return,int,08,29,2024,grid,false
From: https://www.cnblogs.com/XuGui/p/18389633