Total Distance to Nearest Gas Station
Asked at Amazon · Coding Questions · Difficulty: Medium
Trucks sit at the positions in `trucks` on a line; the maximum position is always a gas station (the end). For each query row in `extraGasStations` (a set of additional gas-station positions), every truck drives to its nearest gas station. Return, per query, the total distance driven by all trucks.
Loading the problem…