Back to problems

Shortest Grid Path with Obstacle Eliminations

Algorithm · Mercor · Hard

Implement shortest_path_with_eliminations(grid: list[list[int]], k: int) -> int. A rectangular grid is given where each cell is either 0 (open) or 1 (blocked). You start at the upper-left cell and may move up, down, left, or right to reach the lower-right cell. Entering a blocked cell consumes one elimination. You may enter a blocked cell only while you have at least one remaining elimination, and doing so decreases the remaining budget by 1. Return the fewest moves needed…

Checking your access…