Window over an empty sequence
Updated
If a is empty, n = 0 and there is no legal index. The only window is empty: L = 0, R = -1 (R < L).
What to focus on
Do not name L=0 R=0 on n=0 — index 0 does not exist. Expand is illegal because R+1 < n fails. Empty sequence ⇒ empty window only. This skill is that n = 0 case.
Worked examples
only empty
a = []- n = 0
- L=0 R=-1
- no index is in range
Result: empty window · L=0 R=-1
reject one-cell
a = [], refuse L=0 R=0- R=0 would claim index 0
- n=0 has no slot 0
Result: illegal · stay L=0 R=-1
string empty
s = ""- n = 0
- same sentinel R=-1
- no character to include
Result: empty window · L=0 R=-1
Try it
Write windowOn(a). a is an empty array, or s is an empty string. n = 0. L is 0. R is -1. There is no cell in the window. Print (L, R) = (0, -1). Prove (0, 0) is rejected. Return nothing. Run on a=[] and s="".
a (or s) is empty. n = 0.