Skip to content

Commit cb7951b

Browse files
authored
Update 1970-last-day-where-you-can-still-cross.js
1 parent a33e9e7 commit cb7951b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

1970-last-day-where-you-can-still-cross.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77
const latestDayToCross = function (row, col, cells) {
88
let l = 0,
99
n = cells.length,
10-
r = n - 1,
11-
res = 0
10+
r = n
1211
while (l < r) {
1312
const mid = ~~((l + r) / 2)
1413
if (canWalk(mid)) {
1514
l = mid + 1
16-
res = mid
1715
} else {
1816
r = mid
1917
}
2018
}
2119

22-
return res + 1
20+
return l
2321

2422
function canWalk(mid) {
2523
const grid = Array.from({ length: row }, () => Array(col).fill(0))

0 commit comments

Comments
 (0)