Approach hintTry it first, then revealHide
Rather than searching from every cell, start one multi-source BFS from all zero cells together; the layer at which a cell is first reached is its distance to the nearest zero.
Rather than searching from every cell, start one multi-source BFS from all zero cells together; the layer at which a cell is first reached is its distance to the nearest zero.