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

Question

You are given an R x C grid where each cell is 0 (open) or 1 (a wall). Starting at the top-left (0,0) you may move up/down/left/right; entering an open cell is free but entering a wall costs 1 'break'. Return the minimum number of walls you must break to reach the bottom-right cell (R-1, C-1). The start and goal cells contribute their own cell cost if they are walls. Assume 1 <= R, C <= 1000, so a 0-1 BFS (O(R*C)) is expected rather than Dijkstra with a heap.

Implement
min_wall_breaks(grid: list[list[int]]) → int
Examples
in[[[0,1,0],[0,1,0],[0,0,0]]]out0
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.