I got this question in an interview and I was not able to solve it.
You have a circular road, with N number of gas stations. You know the ammount of gas
While trying each start station of course works fine, it takes quadratic time, while there is a simple linear-time algorithm.
Use a magic car that can keep going if the fuel level runs into the negative. Start at an arbitrary station and do a full tour, visiting every station. If you return with less than zero fuel, there is no solution. Otherwise, the best station to start is the one where the fuel level on arrival was lowest.
This works because the fuel levels of all possible tours are identical except for a constant offset.