miss
to 1, patches
to 0, and i
to 0.miss
is less than or equal to n
:
a. If i
is within the bounds of nums
and nums[i]
is less than or equal to miss
, extend the covered range by adding nums[i]
to miss
and increment i
.
b. If nums[i]
is greater than miss
or i
is out of bounds, patch the array with miss
, increment patches
, and double miss
.