Skip to content

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).

Where the book teaches it

Related terms

Sliding window