Trains the technique from
LeetCode 134Gas StationThis 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.
A survey drone patrols n landing pads laid out on a ring and numbered 0 to n - 1. It always travels in ring order, and the hop out of pad n - 1 brings it back to pad 0.
Sitting on pad i tops the battery up by charge[i] units, and the hop from pad i to the pad after it burns drain[i] units. The drone is placed on a pad of your choosing with a flat battery, tops up there, and then hops from pad to pad until it lands back where it began. The battery is never allowed to fall below zero, so a hop it cannot afford is not permitted.
Return the number of the pad the drone must be placed on to finish the ring, or -1 when no pad works. The input is built so that at most one pad works.
Example 1
Placed on pad 1 the drone tops up to 4 units and spends 1 to reach pad 2, and the battery reads 4, 4, 3 and 1 over the rest of the ring. Pad 0 is hopeless because 3 units cannot pay for a 5 unit hop, and every other placement runs flat before the ring closes.
Example 2
The ring burns 8 units in total but only offers 6, so the drone runs flat somewhere no matter where it is placed.
Example 3
A single pad means one hop straight back to itself, and 6 units of charge covers the 2 units it costs.
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 find_launch_pad(charge: list[int], drain: list[int]) -> int:public int findLaunchPad(int[] charge, int[] drain)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.