public int canCompleteCircuit(int[] gas, int[] cost) {
        
    	int[] diff = new int[gas.length];
    	for (int i = 0; i < gas.length; i++) {
			diff[i] = gas[i] - cost[i];
		}
    	outer:
    	for(int i = 0; i < diff.length; i++) {
    		int sum = 0;
    		if(diff[i] >= 0) {
    			for(int j = i; j < diff.length; j++) {
    				sum += diff[j];
    				if(sum < 0) {
    					continue outer;
    				}
    			}
    			for(int j = 0; j < i; j++) {
    				sum += diff[j];
    				if(sum < 0) {
    					continue outer;
    				}
    			}
    			if(sum >= 0) {
    				return i;
    			}
    		}
    	}
    	return -1;
    }