Advance only the left end
Updated
Advancing only left is L += 1. R stays. You do this when a[L] is finished and a[R] is still useful.
What to focus on
After the move, L is the old L+1 and R is unchanged. The new L is still ≤ R.
Worked examples
first step
a = [4, 1, 9], L=0, R=2- start L=0, R=2
- L += 1
Result: L=1, R=2
meet
a = [4, 1, 9], L=1, R=2- start L=1, R=2
- L += 1
Result: L=2, R=2
one
a = [7], L=0, R=0- start L=0, R=0
- L += 1 would be 1, out
Result: L=0, R=0 · refuse
Try it
Write advanceLeft(a, L, R). a is an array of integers. L is the left index. R is the right index. Do L += 1. Print L and R after the move. Return nothing. On [4, 1, 9] from (0, 2) then (1, 2), and on [4, 1, 9, 1] from (0, 3).
a has length ≥ 2. Start with L < R so the new L is still in range.