grid has 0 (open) and 1 (blocked). Find the shortest path from the top-left cell to the bottom-right cell that only uses open cells and moves in 8 directions (also diagonally). Return the number of cells on the path (both ends included), or -1 if there is no path.
For [[0, 0, 0], [1, 1, 0], [1, 1, 0]] the answer is 4.
Example 1
Input:
shortest_path_binary_matrix([[0, 0, 0], [1, 1, 0], [1, 1, 0]])
Output:
4
Example 2
Input:
shortest_path_binary_matrix([[1, 0], [0, 0]])
Output:
-1
0 <= rows, cols <= 3000 or 1.No results yet
Run your code to check it against the examples, or submit to run every test.