Code RoomMinimum wall breaks
MediumPrep Room Coding #1030

Minimum wall breaks

CodingAlgorithms & data structuresMid–Senior~25 min

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.

0:00 of about 25 min
InputExpectedGot
[[[0,1,0],[0,1,0],[0,0,0]]]0not run yetsample