Example 1

Example 2

1 <= grid.length, grid[i].length <= 1000grid[i][j] is either 0 or 1.The input is generated such that there is at least one 1 in grid.Example 1

Example 2

1 <= grid.length, grid[i].length <= 1000grid[i][j] is either 0 or 1.The input is generated such that there is at least one 1 in grid.