Skip to content

Practice Minimum Obstacle Removal to Reach Corner

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2290
LeetCode Problem

Minimum Obstacle Removal to Reach Corner

Problem Statement

grid uses 0 for empty cells and 1 for removable obstacles. Move from its top-left to bottom-right cell using side-adjacent moves through empty or removed cells. Return the fewest obstacles that must be removed.

Source: Minimum Obstacle Removal to Reach Corner on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
grid = [[0,1,1],[1,1,0],[1,1,0]]
Output
2

# Example 2

Input
grid = [[0,1,0,0,0],[0,1,0,1,0],[0,0,0,1,0]]
Output
0

Constraints

m == grid.length
n == grid[i].length
1 <= m, n <= 10^5
2 <= m * n <= 10^5
grid[i][j] is either 0 or 1.
grid[0][0] == grid[m - 1][n - 1] == 0

Related LeetCode Problems

Practice more problems similar to Minimum Obstacle Removal to Reach Corner.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.