int main() { int gas[4] = {3, 5, 2}; int cost[4] = {4, 6 , 1}; int index = canCompleteCircuit(gas, 4, cost, 4); printf("%d\n", index); return 0; }
int canCompleteCircuit(vector<int> &gas, vector<int> &cost) { if(gas.empty() || cost.empty() || gas.size() != cost.size()) return -1; int lSize = gas.size(); for(int i = 0; i < lSize; i++) { if(canCompleteCircuit(gas, cost, i)) return i; } return -1; }