01 Matrix

In a futuristic city, a team of urban planners is tasked with designing an efficient transportation system. The city is represented as a grid, where each cell can be either a road or a building. The planners want to calculate the minimum distance from each road cell to the nearest building. Implement a function to solve this problem and return the resulting distance matrix.

Examples
Input: [[0,0,0],[0,1,0],[1,1,1]]
Output: [[0,0,0],[0,1,0],[1,2,1]]
Hints

01 Matrix

In a futuristic city, a team of urban planners is tasked with designing an efficient transportation system. The city is represented as a grid, where each cell can be either a road or a building. The planners want to calculate the minimum distance from each road cell to the nearest building. Implement a function to solve this problem and return the resulting distance matrix.