Frog river stone crossing
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.
Implement
frog_jump(stones: list[int]) → boolExamples
in
[[0,1,3,5,6,8,12,17]]outtrueWhat a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 30 min
solution.py
InputExpectedGot
[[0,1,3,5,6,8,12,17]]truenot run yetsample