public int startTour1(int gasAvailable[], int gasRequired[]){
        int diff[] = new int[gasAvailable.length];
        for(int i=0; i < diff.length; i++){
            diff[i] = gasAvailable[i] - gasRequired[i];
        }

        boolean allNegative = true;
        for (int i = 0; i < diff.length; i++) {
            if (diff[i] >= 0) {
                allNegative = false;
                break;
            }
        }

        if (allNegative) {
            return -1;
        }

        KadaneWrapArray kwa = new KadaneWrapArray();
        Triplet t = kwa.kadaneWrap(diff);
        //make sure this solution leads to answer
        int i = t.start;
        int netGas = 0;
        do {
            netGas += diff[i];
            i = (i + 1)%diff.length;
            if (netGas < 0) {
                return -1;
            }
        } while (i != t.start);

        return t.start;
    }
If it is not guaranteed that tour exists then once you get
result of kadanewrap make an actual trip to see if value is positive
@return -1 if no solution exists otherwise returns gas station at which to start.
src/com/interview/array/GasStationCircle.java