ยง
Why a sentinel of
-1
is sensible
See that when we have an array, we usually index it with an array index of
0 <= i < len
.
If
len = 0
, then the only "acceptable"
i
is
-1
, since it's the greatest integer that is less that
len=0
.