Prompt: Given 2 arrays, a = [a0,a1,a2, …, an-1] and b = [b0,b1,b2, …, bn-1], the a array represents the amount of gas that is contained at gas station i and the b array represents the amount of gas needed to get to the next gas station ,in a clockwise direction, from station i. Moreover, the gas stations are circularly linked. For example, the i=n-1 gas station is linked with i=0 gas station. If we are in a car, is there a valid route where we can start at one station and visit all the other stations in a round trip?

Goal: We need to find a valid route where I can start at a certain station and finish visiting all stations in a clockwise direction.

Note: cost of gas <= amount of gas on car + amount of gas available at station

Solution: We just need to loop through all the stations and check if there is a valid route. To check if there is a valid route, the car needs to go through each station and add the gas amount from the station to the current gas amount in the car. We need to check if the gas amount in the car is greater than or equal to the cost of gas that is needed to get to the next gas station. If it is true, then we can subtract that cost from the total amount of gas in the car cause we need to use it to travel to the next station. If it is false, then we don’t have enough gas to move to the next gas station so it can be confirmed that it is not a valid route.