You are given an `m x n` grid `rooms` initialized with three possible values: `-1` (a wall or an obstacle), `0` (a gate), and `2147483647` (INF, representing an empty room). Fill each empty room with the distance to its nearest gate. If it is impossible to reach a gate, it should be filled with `INF`.
Multi-Source BFS
Instead of performing BFS from every empty room (which is slow), we can perform a single BFS starting from ALL gates simultaneously. All gates are at distance 0. Their neighbors are at distance 1, and so on. This 'wave' ensures that each room is updated with its shortest distance to any gate precisely once.