def num_charging_stops(legs: List[int], capacity: int) -> int:
Calculates the number of necessary charging stops to reach the destination.
Each "leg" of your journey represents the amount of energy required to drive
that leg of the trip. For example, if a leg has a value of 5 and your
battery's energy level before driving the leg is 12, then driving that leg
will drop the battery's energy level to 7 (12-5). After driving each leg, you
have the choice of whether to charge or not. If you decide to charge, your
battery's energy level get's returned to "capacity". If you decide not to
charge, your battery's energy level is unchanged. The goal is to calculate
the minimum number of charging stops needed to reach the destination without
ever letting your battery's level fall below 0. If it isn't possible to reach
the destination with the given inputs, -1 should be returned.
Assume that your battery is charged to full capacity to start.
What I have tried:
not been able to find a solution