LeetCode - 150 - Walls and Gates

The problem You are given an m*n 2D grid initialized with these three possible values: -1 - A wall or obstacle. 0 - A gate. INF - Infinity means an empty room. We use the value 2^31 - 1 = 2147483647 to represent INF. Fill each empty room with the distance to its nearest gate. If it’s impossible to reach the gate, it should be filled with INF. Assume the grid can only be traversed up, down, left, or right. ...

October 11, 2025 · 4 min · Dmytro Chumakov