Fewest Refills to Reach a Target Planet When Every Refill Fills the Tank

Asked at Numeric · Coding Questions · Difficulty: Medium

A ship flies along a straight line towards a target planet. It burns one unit of fuel per unit of distance and can only move forward. Refuelling stations sit at fixed positions along the way. Whenever the ship refuels, its tank is filled to a fixed capacity, no matter how much fuel was left. Find the fewest refuelling stops that get the ship to the planet.

Loading the problem…