DIY: Walls and Gates
Explore how to solve the Walls and Gates problem by calculating the shortest distance from empty rooms to gates in a 2D grid. Understand how to represent walls, gates, and empty spaces as input, and implement an efficient solution leveraging breadth-first search techniques. This lesson helps you apply algorithmic problem-solving skills relevant to coding interviews at companies like Amazon.
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 | |