Given a matrix
mat of 0s and 1s. Return a matrix dist where dist[i][j] is the distance from (i, j) to the nearest 0. Adjacent cells are horizontal and vertical neighbors.Example 1
Input: mat = [[0,0,0],[0,1,0],[0,0,0]]
Output: [[0,0,0],[0,1,0],[0,0,0]]
Explanation: The single 1 in the center is at distance 1 from the nearest 0.
Output: [[0,0,0],[0,1,0],[0,0,0]]
Explanation: The single 1 in the center is at distance 1 from the nearest 0.
Example 2
Input: mat = [[0,0,0],[0,1,0],[1,1,1]]
Output: [[0,0,0],[0,1,0],[1,2,1]]
Explanation: Distances in the bottom row are measured to the nearest zeros above and at the edges.
Output: [[0,0,0],[0,1,0],[1,2,1]]
Explanation: Distances in the bottom row are measured to the nearest zeros above and at the edges.