Walls and Gates
Asked at Meta · Coding Questions · Difficulty: Medium · Last asked Apr 21, 2026
You are given an `m x n` grid where each cell is `-1` (a wall), `0` (a gate), or `2147483647` (an empty room, i.e. INF). Fill each empty room with the distance to its nearest gate; if a room cannot reach any gate, leave it as INF. Return the filled grid.
Loading the problem…