Prefix sum
Also written: prefix sums, prefix
A running-total list where `prefix[i]` is the total of the first `i` items, so any range total is one subtraction: `prefix[end] - prefix[start]`. It costs O(n) to build and O(1) per question.
Also written: prefix sums, prefix
A running-total list where `prefix[i]` is the total of the first `i` items, so any range total is one subtraction: `prefix[end] - prefix[start]`. It costs O(n) to build and O(1) per question.