We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ca3ec64 commit daf0682Copy full SHA for daf0682
403-frog-jump.js
@@ -8,18 +8,18 @@ const canCross = function(stones) {
8
return false
9
}
10
11
- let count = new Set(stones)
12
- let lastStone = stones[stones.length - 1]
13
- let position = [0]
14
- let jump = [0]
+ const count = new Set(stones)
+ const lastStone = stones[stones.length - 1]
+ const position = [0]
+ const jump = [0]
15
while (position.length > 0) {
16
- let nextPosition = position.pop()
17
- let nextDistance = jump.pop()
+ const nextPosition = position.pop()
+ const nextDistance = jump.pop()
18
for (let i = nextDistance - 1; i <= nextDistance + 1; i++) {
19
if (i <= 0) {
20
continue
21
22
- let nextStone = nextPosition + i
+ const nextStone = nextPosition + i
23
if (nextStone == lastStone) {
24
return true
25
} else if (count.has(nextStone)) {
0 commit comments