Decide the start of the circular gas station path Suppose there is a circle. There are n petrol pumps on that circle. You are given two sets of data.

The amount of petrol that petrol pump will give.
Distance from that petrol pump to the next petrol pump.

Calculate the first point from where a truck will be able to complete the circle (The truck will stop at each petrol pump and it has infinite capacity). Expected time complexity is O(n). Assume for 1 litre petrol, the truck can go 1 unit of distance.
For example, let there be 4 petrol pumps with amount of petrol and distance to next petrol pump value pairs as {4, 6}, {6, 5}, {7, 3} and {4, 5}. The first point from where truck can make a circular tour is 2nd petrol pump. Output should be “start = 1″ (index of 2nd petrol pump).

Looking for code-review, best-practices and optimizations.
public final class PetrolPumpCircularTour {
    
    private PetrolPumpCircularTour() {};

    public static int startingStations(List&lt;PetrolPumpData&gt; gasStations) {
        
        if (gasStations.size() == 0) {
            throw new IllegalArgumentException(&quot;There should be atleast a single gas stats&quot;);
        }
        
        int front = 0;
        int rear = 0; // is actually 0, after a circle. but 1 is just a game we play for circular queue.
        
        int statationsCovered = 0;
        int gasSavedSoFar = 0;
        
        while (statationsCovered &lt; gasStations.size()) {
            int currentPetrol = gasStations.get(rear).getLitres() + gasSavedSoFar;
            int currentDistance = gasStations.get(rear).getDistance();
            gasSavedSoFar = currentPetrol - currentDistance;
            statationsCovered = statationsCovered + 1;
            
            if (gasSavedSoFar &lt; 0) {
                rear = (rear + 1) % gasStations.size();
                front =  (front + 1) % gasStations.size();
                gasSavedSoFar = 0;
                statationsCovered = 0;
                if (rear == 0) {
                    return -1;
                }
            } else {
                rear = (rear + 1) % gasStations.size();
            }
        }
            
        return front;
    }
}


public class PetrolPumpCircularTourTest {
    
    @Test
    public void test1( ) {
        List&lt;PetrolPumpData&gt; list1 = new ArrayList&lt;PetrolPumpData&gt;();
        list1.add(new PetrolPumpData(4, 6));
        list1.add(new PetrolPumpData(6, 5));
        list1.add(new PetrolPumpData(7, 3));
        list1.add(new PetrolPumpData(4, 5));
        
        assertEquals(1, PetrolPumpCircularTour.startingStations(list1));
    }
    
    @Test
    public void test2() {
        List&lt;PetrolPumpData&gt; list2 = new ArrayList&lt;PetrolPumpData&gt;();
        list2.add(new PetrolPumpData(40, 6));
        list2.add(new PetrolPumpData(6, 5));
        list2.add(new PetrolPumpData(7, 3));
        list2.add(new PetrolPumpData(4, 5));
        
        assertEquals(0, PetrolPumpCircularTour.startingStations(list2));
    }
    
    @Test
    public void test3() {
        List&lt;PetrolPumpData&gt; list3 = new ArrayList&lt;PetrolPumpData&gt;();
        list3.add(new PetrolPumpData(4, 6));
        list3.add(new PetrolPumpData(3, 5));
        list3.add(new PetrolPumpData(70, 3));
        list3.add(new PetrolPumpData(4, 5));
        
        assertEquals(2, PetrolPumpCircularTour.startingStations(list3));
    }
    
    @Test
    public void test4( ) {
        List&lt;PetrolPumpData&gt; list4 = new ArrayList&lt;PetrolPumpData&gt;();
        list4.add(new PetrolPumpData(4, 6));
        list4.add(new PetrolPumpData(3, 5));
        list4.add(new PetrolPumpData(2, 3));
        list4.add(new PetrolPumpData(40, 5));
        
        assertEquals(3, PetrolPumpCircularTour.startingStations(list4));
    }
}
Can you prove the algorithm works? It really looks suspicious. Besides, running it against a

{4,6}, {6,5}, {1,3}, {7,3}, {4,5}


test case returns 2. (Hint: the correct algorithm is much simpler).