Glossary: Coding Interviews in Go
Prefix sum
Also written: prefix sums, pattern 11
A running-total slice where `prefix[i]` is the total of the first `i` items, so any range total is `prefix[end] - prefix[start]` in O(1). Setup costs O(n).
Glossary: Coding Interviews in Go
Also written: prefix sums, pattern 11
A running-total slice where `prefix[i]` is the total of the first `i` items, so any range total is `prefix[end] - prefix[start]` in O(1). Setup costs O(n).