stones; the frog sits on the first stone (position 0) and wants to reach the last one. It can only jump forward and only onto stones, never into the water.
The first jump is exactly 1 unit. If the previous jump had length k, the next one may have length k - 1, k or k + 1 (always positive).
Return True if the frog can reach the last stone, and False otherwise.stones=[0, 1, 2, 4, 7] → True
Jumps of 1, 1, 2 and 3: each one differs from the previous by at most 1.
stones=[0, 2] → False
The first jump must be exactly 1, and there is no stone at position 1.
stones=[0, 1, 3, 4, 8] → False
The frog can reach the stone at 4, but from there it can jump at most 2 units, while 8 is 4 units away.
stones is strictly increasingstones=[0, 1, 2, 4, 7]
True
Run checks the first 3 tests in your browser. Submit checks all 85 tests on the server, hidden ones included.