Matrix Toolbox
Handy Python snippets and patterns for working with 2D grids and matrices: initialization, bounds checking, neighbor offsets, and n-distance neighbors.
Handy Python snippets and patterns for working with 2D grids and matrices: initialization, bounds checking, neighbor offsets, and n-distance neighbors.
Prefix sums (cumulative sums) are a foundational technique for speeding up range queries. They extend beyond arrays into matrices, trees, and even XOR or product computations, forming the backbone of many algorithmic optimizations.