1 KiB
1 KiB
slug | title | author | order |
---|---|---|---|
/silver/prefix-sums | Prefix Sums | Eric Wei (incomplete) | 6 |
Description: Todo
The Task
Given an array of size N
, answer Q
queries of the following form: Find the sum of all elements between indices i
and j
.
Tutorials
(This technique is also known as cumulative sum or partial sums.)
See Ch 11 of https://www.overleaf.com/project/5e73f65cde1d010001224d8a
- CPH 9.1
Extensions
2D Prefix Sums
Given a 2-Dimension array of size NxM
, answer Q
queries of the following form: Find the sum of all elements within the rectangle of indices (x1,y1)
to (x2,y2)
.
Difference Array
Consider the array formed by a_i-a_{i-1}
.
- USACO Painting the Barn (i should find an easier one because this is hard)
Prefix Minimum, Etc.
Using