Code Room
CodingMediumcod-g249
Subject 0 1 bfsLevel Mid–Senior~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

You are given a grid where grid[r][c] is 0 for an empty cell and 1 for an obstacle. Starting at the top-left (0,0) and moving up/down/left/right, you may eliminate obstacles; return the minimum number of obstacles you must remove to reach the bottom-right corner. Entering an obstacle cell costs one removal. The grid is at least 1x1 and the start/end may themselves be obstacles. Constraints: 1 <= rows, cols <= 100.

Implement
min_obstacles_to_remove(grid: list[list[int]]) → int
Examples
in[[[0,1,1],[1,1,0],[1,1,0]]]out2
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.