Trains the technique from
LeetCode 403Frog JumpThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
An inspection crawler walks a pipeline by hopping between steel pads bolted to the outside of the pipe. pads lists the distance of each pad from the pump house in metres, sorted strictly increasing, and pads[0] is always 0 because the crawler is parked on the first pad.
Hops obey two rules:
k metres, its next hop must cover k - 1, k or k + 1 metres. A hop always moves forward, so its length must be at least 1 metre.Every hop has to finish on a pad; landing on bare pipe is not allowed, and the crawler may not skip a hop or move backwards.
Return true if the crawler can get from the first pad to the last pad in pads, and false otherwise. Pads in between may be passed over.
Example 1
Hops of 1, 1, 2, 3 and 4 metres land on pads 1, 2, 4, 7 and 11. The first hop is 1 metre and every later hop is within 1 metre of the one before it.
Example 2
The opening hop has to cover exactly 1 metre, and there is no pad 1 metre along, so the crawler never leaves the first pad.
Example 3
Hops of 1, 2, 3 and 2 metres land on pads 1, 3, 6 and 8. Each hop length is within 1 metre of the previous hop, and the 2-metre finish is one metre shorter than the 3-metre hop before it.
Example 4
Pad 6 can only be entered with a 3-metre hop, after hops of 1 and 2 metres. A 3-metre hop must be followed by one of 2, 3 or 4 metres, which land on bare pipe at 8, 9 and 10, and pad 7 stays out of reach by every other legal sequence too.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def can_reach_last_pad(pads: list[int]) -> bool:public boolean canReachLastPad(int[] pads)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.