Skip to content

Commit 6f8c1b4

Browse files
committed
Add comments about how to mark the path.
1 parent 0d25362 commit 6f8c1b4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

1091.shortest-path-in-binary-matrix.java

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
// You should always discuss the possibility of overwriting the input with your interviewer
2222
// and clarify what kind of environment your algorithm is expected to run in.
2323

24+
// How to mark the path?
25+
// We can mark the value of cell as the current distance (step), so after reaching
26+
// target, we can implement the backtracing method, check all the currDis-1 cell to find the pre step.
2427
class Solution {
2528
int[][] dirs = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 }, { 1, 1 }, { -1, -1 }, { -1, 1 }, { 1, -1 } };
2629

0 commit comments

Comments
 (0)