Tap here to switch tabs
Problem
Submissions

Problem: Minimum Obstacle Removal to Reach Corner

Try to solve the Minimum Obstacle Removal to Reach Corner problem.

Statement

You are given a 00 indexed 2D2 {D} integer array grid of size m ×\times n. Each cell in grid contains either:

  • 00, representing an empty cell, or

  • 11, representing an obstacle that can be removed.

You can travel between cells by moving up, down, left, or right to an adjacent cell.

Return the minimum number of obstacles you need to remove to travel from the top left cell (0, 0) to the bottom right cell (m - 1, n - 1).

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 1≤1 \leq m, n ≤105\leq 10^5

  • 2≤2 \leq m ×\times n ≤105\leq 10^5

  • grid[i][j] is either 00 or 11.

  • grid[0][0] ==== grid[m - 1][n - 1] ==0== 0

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Obstacle Removal to Reach Corner

Try to solve the Minimum Obstacle Removal to Reach Corner problem.

Statement

You are given a 00 indexed 2D2 {D} integer array grid of size m ×\times n. Each cell in grid contains either:

  • 00, representing an empty cell, or

  • 11, representing an obstacle that can be removed.

You can travel between cells by moving up, down, left, or right to an adjacent cell.

Return the minimum number of obstacles you need to remove to travel from the top left cell (0, 0) to the bottom right cell (m - 1, n - 1).

Constraints:

  • m ==== grid.length

  • n ==== grid[i].length

  • 1≤1 \leq m, n ≤105\leq 10^5

  • 2≤2 \leq m ×\times n ≤105\leq 10^5

  • grid[i][j] is either 00 or 11.

  • grid[0][0] ==== grid[m - 1][n - 1] ==0== 0