Gas Station

Greedy ยท medium

Given `gas` and `cost` arrays, implement `canCompleteCircuit(gas, cost)` returning the starting index from which you can travel the full circle once, or `-1` if impossible. A unique answer exists when possible.

Learning resources

Loading...

Run your code to see results.