You are given a binary matrix grid of size m n.
From any cell
The matrix is disconnected if there is no valid path from the top left cell m n
You are allowed to flip the value of at most one cell from m n
Return true if it is possible to make the matrix disconnected after flipping at most one cell, or false otherwise.
Note: Flipping at most one cell means you can choose to flip
or cell. A path is valid only if every cell visited has a value of .
Constraints:
m grid.length
n grid[i].length
m, n
m n
grid[i][j] is either
grid[0][0] grid[m - 1][n - 1]
You are given a binary matrix grid of size m n.
From any cell
The matrix is disconnected if there is no valid path from the top left cell m n
You are allowed to flip the value of at most one cell from m n
Return true if it is possible to make the matrix disconnected after flipping at most one cell, or false otherwise.
Note: Flipping at most one cell means you can choose to flip
or cell. A path is valid only if every cell visited has a value of .
Constraints:
m grid.length
n grid[i].length
m, n
m n
grid[i][j] is either
grid[0][0] grid[m - 1][n - 1]