Optimal Algorithmic Approach
Multi-source BFS from all gates at once.
Core Invariants & Edge Cases
- Start BFS from all gates (value 0) simultaneously
- The first time a cell is reached is its shortest distance
- Walls (value -1) block propagation
Fill each empty room with the distance to its nearest gate using multi-source BFS.
Multi-source BFS from all gates at once.
Coding interviews are only 50% of the bar. Master High-Level Design, distributed systems, and Object-Oriented LLD.