Jumping to last stone
Stepping stones cross a creek, numbered 0 to n-1 from the near bank. hops[i] is the farthest number of stones you can leap forward from stone i (0 means that stone is a dead end). You start on stone 0. Return True if you can reach the last stone. Example: hops [2, 1, 0, 1] is False — every route strands you on stone 2.
Implement
can_cross(hops: list[int]) → boolExamples
in
[[2,1,0,1]]outfalseWhat 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 12 min
solution.py
InputExpectedGot
[[2,1,0,1]]falsenot run yetsample