今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

Algorithem_Matrix

Algorithem_Matrix#

题目#

Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.

The distance between two adjacent cells is 1.

Example 1:

image1

Input: mat = [[0,0,0],[0,1,0],[0,0,0]]
Output: [[0,0,0],[0,1,0],[0,0,0]]

Example 2:

image2

Input: mat = [[0,0,0],[0,1,0],[1,1,1]]
Output: [[0,0,0],[0,1,0],[1,2,1]]

解法#

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.