Fill Rooms with Distance to the Nearest Gate

Asked at Meta · Coding Questions · Difficulty: Medium

You are given a grid of rooms. Some rooms are gates, some are empty, and some cells are walls. For every empty room, work out how many steps it takes to walk to the nearest gate, and write that number into the grid.

Loading the problem…