public static int canCompleteCircuit(int[] gas, int[] cost) {
        assert gas.length == cost.length;
    	int len = gas.length;
    	for (int i = 0; i < len; i++) {
    		int tank = 0;
    		int start = i;
    		boolean done = true;
    		int step = start;
    		for (int j = 0; j < len; j++) {
    			tank = tank + gas[step] - cost[step];
    			if (tank < 0) {done = false; break;}
    			step = (step + 1) % len;
    		}
    		if (done) {
    			return start;
    		}
    	}
    	return -1;
    }