Is that solution correct ? Complete Circuit
Briefly

In the line $start = $i + 1; we are marking the next station as a new potential starting point whenever the fuel tank goes negative.
If $tank < 0, it indicates that starting from the current 'start' position will not allow us to complete the circuit, requiring us to move the starting position.
Even though $i increments after updating $start, the next iteration still considers the interval from the last unsuccessful position, hence checking all possible start stations.
Ultimately, the success of swirling back relies on whether the total supply of gas is greater than or equal to the total cost required.
Read at SitePoint Forums | Web Development & Design Community
[
|
]