// here our traverse stops at i == nums.length -2 // if as this case, i == curRange, it naturally // need one more step, and res would increase by 1 // else, it means that the curRangg has already covered // the nums.length - 1 for (inti=0; i < nums.length - 1; i++) { potential = Math.max(potential, i + nums[i]);
if (i == curRange) { res++; curRange = potential; } }