Trail marker reachability
A hiking game shows a trail of markers. Standing on marker i, your stamina lets you advance to any marker from i+1 up to i+jumps[i]; a value of 0 means you are stuck there. You start on the first marker. Return true if the last marker can be reached, false otherwise. A single-marker trail is trivially finished. For example, [2, 3, 1, 1, 4] is finishable but [3, 2, 1, 0, 4] is not.
Implement
can_finish_trail(jumps: list[int]) → boolExamples
in
[[2,3,1,1,4]]outtruein
[[3,2,1,0,4]]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,3,1,1,4]]truenot run yetsample[[3,2,1,0,4]]falsenot run yetsample