Why the list starts with zero.
transcript
One list answers every range. It starts with a zero. Without it, the formula breaks at the start. Why the zero?
Prefix i is the total of the first i values. Prefix zero is zero. A range is prefix right plus one, minus prefix left. The list has one more entry than the values.
Take days zero to six. The end entry is prefix seven, thirty eight. The start entry is prefix zero, which is zero. Thirty eight minus zero is thirty eight. No special case. The zero is the total of no days.
Drop the zero, and prefix i covers one more value. Days two to five become thirty minus sixteen. That is fourteen. The right answer is twenty three. A range from zero needs an extra check. The zero removes that check.
Start the list with a zero. Add each value to a running total. Subtract with right plus one. Every question costs one subtraction.
A zero, and right plus one. Full breakdown in the lecture.