In Meta infrastructure, a service health map can be modeled as a 2D grid where 0 means a healthy traversable node and 1 means a blocked node. Write pseudocode-level logic as an actual function to compute the minimum number of moves needed to go from the top-left node to the bottom-right node.
You may move only up, down, left, or right. Return the length of the shortest path if one exists, otherwise return -1.
grid, a list of lists of integers, where each value is either 0 or 1(0, 0) to (rows - 1, cols - 1), or -1 if unreachableExample 1
grid = [[0,0,0],[1,1,0],[0,0,0]]4(0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2).Example 2
grid = [[0,1],[1,0]]-11 <= rows, cols <= 200grid[i][j] is either 0 or 1grid[0][0] == 1 or grid[rows-1][cols-1] == 1, the answer is -1