File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,18 @@ const canCross = function(stones) {
8
8
return false
9
9
}
10
10
}
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 ]
15
15
while ( position . length > 0 ) {
16
- let nextPosition = position . pop ( )
17
- let nextDistance = jump . pop ( )
16
+ const nextPosition = position . pop ( )
17
+ const nextDistance = jump . pop ( )
18
18
for ( let i = nextDistance - 1 ; i <= nextDistance + 1 ; i ++ ) {
19
19
if ( i <= 0 ) {
20
20
continue
21
21
}
22
- let nextStone = nextPosition + i
22
+ const nextStone = nextPosition + i
23
23
if ( nextStone == lastStone ) {
24
24
return true
25
25
} else if ( count . has ( nextStone ) ) {
You can’t perform that action at this time.
0 commit comments