1
var canCompleteCircuit = function (gas, cost) {2
const len = gas.length;3
// scan forward from the current index8
while (numTries <= len) {10
if (tank < 0) return -1;11
// if we made it back around, and we have gas, return the index, we made it!12
if (numTries === len && tank >= 0) {18
if (i === len) i = 0; // if we hit the end, bounce back to zero24
for (let i = 0; i < len; i++) {25
if (!gas[i]) continue; // no gas / zero gas so let's just move on27
if (~index) return index; // if it's not -1, return it