Skip to content

Commit daf0682

Browse files
authored
Update 403-frog-jump.js
1 parent ca3ec64 commit daf0682

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

403-frog-jump.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ const canCross = function(stones) {
88
return false
99
}
1010
}
11-
let count = new Set(stones)
12-
let lastStone = stones[stones.length - 1]
13-
let position = [0]
14-
let jump = [0]
11+
const count = new Set(stones)
12+
const lastStone = stones[stones.length - 1]
13+
const position = [0]
14+
const jump = [0]
1515
while (position.length > 0) {
16-
let nextPosition = position.pop()
17-
let nextDistance = jump.pop()
16+
const nextPosition = position.pop()
17+
const nextDistance = jump.pop()
1818
for (let i = nextDistance - 1; i <= nextDistance + 1; i++) {
1919
if (i <= 0) {
2020
continue
2121
}
22-
let nextStone = nextPosition + i
22+
const nextStone = nextPosition + i
2323
if (nextStone == lastStone) {
2424
return true
2525
} else if (count.has(nextStone)) {

0 commit comments

Comments
 (0)