// TOPIC
#prefix-sums
2 articles
◆◆◆AdvancedGoogle
01Fenwick Trees (Binary Indexed Trees)
Fenwick trees give you O(log n) prefix-sum queries AND point updates in ~10 lines of code — leaner and faster in practice than a segment tree for this exact job. Learn the lowbit trick, build the tree, and know when a BIT beats everything else.
#fenwick-tree#binary-indexed-tree#prefix-sums
13 min◆◆IntermediateAmazonGoogle
02Prefix Sums
Precompute running totals so any range sum becomes one subtraction. The prefix sum technique turns O(n) per query into O(1) — and the hashmap combo unlocks a whole class of subarray counting problems.
#arrays#prefix-sums#techniques
10 min