Frog river stone crossing

Write codeHard30 minGoogle style

Your task

A frog crosses a river by jumping on stones at the given strictly-increasing positions (the first stone is at 0). Its first jump must be exactly 1 unit. After a jump of k units the next jump must be k-1, k, or k+1 units (and must be positive), landing exactly on a stone. Return whether the frog can reach the last stone. The list has at least one stone.

Examples

frog_jump(stones: list[int]) -> bool
Example 1
Inputfrog_jump([0, 1, 3, 5, 6, 8, 12, 17])
OutputTrue