Your question is Gas Station / Oasis / Car Path. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A Bloomberg Terminal field vehicle must travel through a circular sequence of service stations. At station i, it can collect fuel[i] units of fuel, then needs distance[i] units to reach station (i + 1) % n.
Implement can_complete_circuit(fuel, distance) to return an index from which the vehicle can visit every station exactly once and return to its starting station. Return -1 if no such starting station exists. Assume the vehicle starts with an empty tank and has unlimited tank capacity.
fuel: a list of n nonnegative integers, where fuel[i] is fuel available at station i.distance: a list of n nonnegative integers, where distance[i] is fuel required to travel from station i to the next station.[0, n - 1], or -1 when completing the circuit is impossible.def can_complete_circuit(fuel, distance):