Algorithms & Data Structures
Beginner
Pro
Prefix Sums
Turn repeated range queries into O(1) lookups with one cheap pass
20 min read
0 views
Learn the prefix-sum technique for answering range-sum queries in constant time after linear preprocessing, and its two most common interview extensions: counting subarrays with a target sum using a hash map, and computing products without division using prefix/suffix products.