Gas Station
Medium
Greedy
There are n gas stations on a circular route. gas[i] is the fuel available at station i and cost[i] is the fuel needed to travel to the next station. Print the index of the station from which you can complete the full circle once, or -1 if impossible. If a solution exists it is unique.
Constraints
1 <= n <= 10^5 0 <= gas[i], cost[i] <= 10^4
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.