Prefix Sum
Everything on SkillVeris tagged Prefix Sum — collected across the glossary, study notes, blog, and cheat sheets.
5 resources across 1 library
Interview Questions(5)
What is Counting Sort?
Counting sort sorts integers by counting how many times each distinct value occurs, converting those counts into prefix sums that give each value its final pos…
What is a Segment Tree?
A segment tree is a binary tree built over an array that stores a precomputed aggregate (sum, min, max, or similar) for every contiguous sub-range at each node…
What is a Fenwick Tree (Binary Indexed Tree)?
A Fenwick tree, or binary indexed tree, is an array-backed structure that answers prefix-sum queries and supports point updates in O(log n) time using O(n) spa…
How Do You Find the Number of Subarrays That Sum to K?
You solve subarray-sum-equals-k in O(n) time by tracking a running prefix sum and a hash map of how many times each prefix sum value has occurred so far, since…
How Do You Find a Subarray With a Given Sum?
For arrays of non-negative integers, a sliding window expands and shrinks two pointers over the array to find a contiguous subarray summing to a target in O(n)…