public int startTour(int gasAvailable[],int gasRequired[]){
        int start = -1;
        int end = 0;
        int currentGas = 0;
        boolean visitedOnce = false;
        while(start != end){
            currentGas += gasAvailable[end] - gasRequired[end];
            if(start == -1){
                start = end;
            }
            if(end == gasAvailable.length-1 && visitedOnce == false){
                visitedOnce = true;
            }else if(end == gasAvailable.length-1 && visitedOnce == true){
                return -1;
            }
            if(currentGas < 0){
                start = -1;
                currentGas = 0;
            }
            end = (end + 1)%gasAvailable.length;
        }
        
        return end;
    }
http://www.geeksforgeeks.org/find-a-tour-that-visits-all-stations/
You can solve this one using kadane wrap since it finds max contiguous sum
for wrapped array. That start point is a best place to start a tour.
Test cases
Check if length of both input array is same
Check that there exists a path after kadane wrap responds
Check that there is at least one positive difference before you call kadane
src/com/interview/array/GasStationCircle.java