Skip to main content
Back to problems
Leetcode
Medium
Matrices
Arrays
Check If Grid Satisfies Conditions

Determine whether a small grid satisfies a set of local cell-by-cell constraints.

Acceptance 0%
Problem Statement

Given an m×nm \times n grid of integers, check whether it satisfies a set of local conditions involving each cell and its neighboring cells.

In this problem, you inspect the grid directly and verify that every required condition holds. The task is primarily about careful iteration over the matrix and correctly handling boundaries when comparing neighboring values.

Return whether the grid satisfies all conditions.

Input Format

  • An integer grid with mm rows and nn columns.
  • Each cell contains an integer value.
  • The exact validity rule is determined by the problem statement for each cell and its adjacent cells.

Output Format

  • Return true if the grid satisfies all required conditions.
  • Otherwise, return false.

Constraints

  • The grid size is finite and small enough for direct iteration.
  • Values are integers.
  • Boundary cells must be handled safely when checking neighbors.
Examples
Sample cases returned by the problem API.

Example 1

Input

grid = [[1,0,1],[1,1,0]]

Output

true

Explanation

All cells satisfy the required local checks for this example grid.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.