farthest
to 0, which will keep track of the farthest index we have checked.minJump
and maxJump
, and update farthest
.
d. Iterate through the range and add valid indices (where s[i] == '0'
) to the queue.
e. Update farthest
to the maximum of its current value and the right boundary of the current range.