4
* @param {number[][]} cells7
var latestDayToCross = function (row, col, cells) {12
.map((el) => Array(col).fill(0));15
// Check if path exists16
function isExistPath() {19
if (i === row || j === col || j < 0 || i < 0) return false;20
if (ground[i][j] === 1) return false;21
if (i === row - 1) return true;23
return dfs(i + 1, j) || dfs(i, j - 1) || dfs(i, j + 1) || dfs(i - 1, j);25
for (let j = 0; j < col; j++) if (dfs(0, j)) return true;29
//fill the ground and check paths30
function isGoodGround(end) {32
for (let i = 0; i <= end; i++) ground[cells[i][0] - 1][cells[i][1] - 1] = 1;36
//binary search by day40
const mid = (l + r) >>> 1;41
if (isGoodGround(mid)) l = mid;