Tap here to switch tabs
Problem
Submissions

Problem: Check if Grid Satisfies Conditions

med
30 min
Try to solve the Check if Grid Satisfies Conditions problem.

Statement

You are given a 2D2 D integer matrix grid of size n×mn \times m. You need to determine whether all cells in the matrix satisfy the following conditions:

  • Every cell is equal to the cell directly below it, such that grid[i][j] == grid[i + 1][j] for all valid indices.

  • Every cell is different from the cell directly to its right, such that grid[i][j] != grid[i][j + 1] for all valid indices.

Return true if all cells satisfy these conditions, or false otherwise.

Constraints:

  • 1≤n,m≤101 \leq n, m \leq 10

  • 0≤0 \leq grid[i][j] ≤9\leq 9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Check if Grid Satisfies Conditions

med
30 min
Try to solve the Check if Grid Satisfies Conditions problem.

Statement

You are given a 2D2 D integer matrix grid of size n×mn \times m. You need to determine whether all cells in the matrix satisfy the following conditions:

  • Every cell is equal to the cell directly below it, such that grid[i][j] == grid[i + 1][j] for all valid indices.

  • Every cell is different from the cell directly to its right, such that grid[i][j] != grid[i][j + 1] for all valid indices.

Return true if all cells satisfy these conditions, or false otherwise.

Constraints:

  • 1≤n,m≤101 \leq n, m \leq 10

  • 0≤0 \leq grid[i][j] ≤9\leq 9