The trivial case when there is only one station should not return -1 as th person does not have to move. Currently OJ gives answer depending on the difference of cost and gas at the station.
does not have to move
How do you " travel around the circuit once" without moving?
That's the point, you do not need move. The condition: "travel around the circuit once" is trivially satisfied. Anyway the answer to n=1 case should be irrespective of how much gas and cost we have at the station. Or either explicitly say that n is at least 2 as it does not make sense to go from city 1 to city 1.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.