Back to course home
0% completed
Walls and Gates (medium)
Problem Statement
You are given a grid of size m x n
filled with three possible values:
-1
representing a wall or an obstacle.0
representing a gate.2147483647
(INF) representing an empty room.
Fill each empty room with the distance to its nearest gate. If an empty room cannot reach any gate, it should remain 2147483647
.
Examples
Example 1
- Input:
[[2147483647, -1, 0], [2147483647, 2147483647, 2147483647], [2147483647, -1, 2147483647]]
- Expected Output:
[[4, -1, 0], [3, 2, 1], [4, -1, 2]]
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible