2025-08-22 17:22:48 +0000 UTC

Check if Grid Satisfies Conditions

Code

class Solution:
    def satisfiesConditions(self, grid: List[List[int]]) -> bool:
        rows, cols = len(grid), len(grid[0])
        for row in range(rows):
            for col in range(cols):
                val = grid[row][col]
                if row + 1 < rows and val != grid[row + 1][col]:
                    return False
                if col + 1 < cols and val == grid[row][col + 1]:
                    return False
        return True