Given a square binary matrix grid of size n x n, find the length of the shortest clear path from the top left cell to the bottom right cell.
A clear path is a sequence of cells such that every visited cell has value grid[0][0] and ends at grid[n-1][n-1]. Return the number of cells in the shortest such path. If no clear path exists, return
Note: Movement is allowed to any of the
neighboring cells (horizontal, vertical, and diagonal).
Constraints:
n == grid.length
n == grid[i].length
n
grid[i][j] is
Given a square binary matrix grid of size n x n, find the length of the shortest clear path from the top left cell to the bottom right cell.
A clear path is a sequence of cells such that every visited cell has value grid[0][0] and ends at grid[n-1][n-1]. Return the number of cells in the shortest such path. If no clear path exists, return
Note: Movement is allowed to any of the
neighboring cells (horizontal, vertical, and diagonal).
Constraints:
n == grid.length
n == grid[i].length
n
grid[i][j] is