DIY: Walls and Gates
Explore how to fill empty rooms in a grid with the distance to their nearest gate by implementing an effective algorithm. Learn to manage obstacles and optimize search in a 2D array, preparing for similar technical problems faced in Amazon interviews.
We'll cover the following...
We'll cover the following...
Problem
You are given a grid represented by a 2D array named rooms. The grid represents rooms where a cell can either be a wall, a gate, or an empty space. The rooms are initialized with these three possible values.
| Values | Represents |
|---|---|
| A wall or an obstacle | |