public int canCompleteCircuit(int[] gas, int[] cost) {

		int previous = 0;
		int index = 0;
		int restGas = 0;
		for (int i = 0; i < gas.length; i++) {
			restGas += gas[i] - cost[i];

			if (restGas < 0) {
				previous += restGas;
				restGas = 0;
				index = i + 1;
			}
		}

		if (restGas + previous >= 0) {
			return index;
		} else {
			return -1;
		}
	}