public int canCompleteCircuit(int[] gas, int[] cost) {
        int start = 0, index = 0;
        int tank = 0, left = 0;
        while(index < gas.length){
            left += gas[index] - cost[index];
            tank += gas[index] - cost[index];
            if(tank < 0){
                start = index + 1;
                index = start;
                tank = 0;
            }else{
                index++;
            }
        }
        return left < 0 ? -1 : start;
    }