Practice Stamping the Grid
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
grid uses 0 for empty cells and 1 for occupied cells. Place any number of axis-aligned stampHeight by stampWidth stamps, wholly inside the grid, to cover every empty cell and no occupied cell. Stamps may overlap but cannot rotate. Return whether this is possible.
Source: Stamping the Grid on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
grid = [[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0],[1,0,0,0]], stampHeight = 4, stampWidth = 3
Output
true
# Example 2
Input
grid = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]], stampHeight = 2, stampWidth = 2
Output
false
Constraints
m == grid.length
n == grid[r].length
1 <= m, n <= 10^5
1 <= m * n <= 2 * 10^5
grid[r][c] is either 0 or 1.
1 <= stampHeight, stampWidth <= 10^5
Related LeetCode Problems
Practice more problems similar to Stamping the Grid.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.