Suppose there is a circle. There are N petrol pumps on that circle. You will be given two sets of data.
- The amount of petrol that every petrol pump has.
- Distance from that petrol pump to the next petrol pump.
Find a starting point where the truck can start to get through the complete circle without exhausting its petrol in between.
Note : Assume for 1 litre petrol, the truck can go 1 unit of distance.
- Time : O(n)
- Space : O(1)
1 | class Solution { |