Given an
n × n binary matrix grid. Return the length of the shortest path from (0, 0) to (n - 1, n - 1) moving in 8 directions on cells with value 0. If no path exists, return -1.Example 1
Input: grid = [[0,1],[1,0]]
Output: 2
Explanation: Shortest path along the diagonal.
Output: 2
Explanation: Shortest path along the diagonal.
Example 2
Input: grid = [[0,0,0],[1,1,0],[1,1,0]]
Output: 4
Explanation: Navigating obstacles in a 3×3 matrix.
Output: 4
Explanation: Navigating obstacles in a 3×3 matrix.