Problem
Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.
The distance between two adjacent cells is 1.
Java
BFS
1 | class Solution { |
Submission Detail
- 48 / 48 test cases passed.
- Runtime: 14 ms, faster than 64.69% of Java online submissions for 01 Matrix.
- Memory Usage: 44 MB, less than 100.00% of Java online submissions for 01 Matrix.