3142. 判断矩阵是否满足条件
题目链接:3142. 判断矩阵是否满足条件
代码如下:
class Solution
{
public:
bool satisfiesConditions(vector<vector<int>>& grid)
{
for(int i=0;i<grid.size();i++)
{
for(int j=0;j<grid[i].size();j++)
{
if(i<grid.size()-1)
{
if(grid[i][j]!=grid[i+1][j]) {return false;}
}
if(j<grid[i].size()-1)
{
if(grid[i][j] == grid[i][j + 1]) {return false;}
}
}
}
return true;
}
};