var canCompleteCircuit = function(gas, cost) {
if(sum(gas) < sum(cost)) return -1;
let start = 0;
let fuel = 0;
for(let i = 0; i < gas.length; i++){
if(gas[i] + fuel < cost[i]){
start = i + 1;
fuel = 0;
} else {
fuel += gas[i] - cost[i];
}
}
return start;
};
const sum = (numbers) => {
return numbers.reduce((acc, curr) => acc + curr, 0)
}