I use the following input to test my code :
gas [4 0 1]
cost [3 2 1]
and the OJ show the expected answer is 2 instead of -1. Is this an error for the Run code test?
Hi, i just tried the input test case you have mentioned in the question for the gas station problem. The OJ gives output -1 and not 2. Recheck it you might by mistake given other input case.
It seems that this only happens to C++ version. I tried Java and Python and both the answers are correct .
I just realized that it is 2. Because if you start from 2, you can get to 1 by [2 0 1], after you got 1, you don't need to move on. You already finished it! So the OJ is correct, isn't it?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.