Code RoomJumping to last stone
EasyPrep Room Coding #637

Jumping to last stone

CodingAlgorithms & data structuresEntry–Mid~12 min

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]) → bool
Examples
in[[2,1,0,1]]outfalse
What 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
InputExpectedGot
[[2,1,0,1]]falsenot run yetsample