🐐
LeetGoat
Interview Prep
Competitive Programming
Discord
2D Range Query Picker
Range queries
2D range queries
Sets
Union find
Strings
Tree queries
Tree helpers
Graphs
Matrices
Math
Primes
Bit ops & Bitset
Geometry
Misc.
Golden References
2D
3D
Generic sparse tables ▾
(x, y) coordinates
Small grid (R × C)
Compressed coordinates
Nothing known (online)
Unselect all
Point operations
pointGet
(r, c)
Read one cell
getAll
()
Read the whole grid (e.g. after many rectangle adds)
pointAssign
(r, c, v)
cell = v (can go down as well as up)
pointAdd
(r, c, v)
cell += v
pointChmax
(r, c, v)
cell = max(cell, v)
pointChmin
(r, c, v)
cell = min(cell, v)
Rectangle queries
rows r1..r2, columns c1..c2, inclusive
rectSum
(r1, c1, r2, c2)
Sum of the rectangle
sumAll
()
Sum of everything
rectMin
(r1, c1, r2, c2)
Min of the rectangle
minAll
()
Min of everything
rectMax
(r1, c1, r2, c2)
Max of the rectangle
maxAll
()
Max of everything
rectGcd
(r1, c1, r2, c2)
Gcd of the rectangle
gcdAll
()
Gcd of everything
Bit ops
rectXor
(r1, c1, r2, c2)
XOR of the rectangle
xorAll
()
XOR of everything
rectAnd
(r1, c1, r2, c2)
AND of the rectangle
andAll
()
AND of everything
rectOr
(r1, c1, r2, c2)
OR of the rectangle
orAll
()
OR of everything
Corner queries
sum
sumLteLte
(r, c)
sum over row ≤ r and column ≤ c
sumLteGte
(r, c)
sum over row ≤ r and column ≥ c
sumGteLte
(r, c)
sum over row ≥ r and column ≤ c
sumGteGte
(r, c)
sum over row ≥ r and column ≥ c
max
maxLteLte
(r, c)
max over row ≤ r and column ≤ c
maxLteGte
(r, c)
max over row ≤ r and column ≥ c
maxGteLte
(r, c)
max over row ≥ r and column ≤ c
maxGteGte
(r, c)
max over row ≥ r and column ≥ c
min
minLteLte
(r, c)
min over row ≤ r and column ≤ c
minLteGte
(r, c)
min over row ≤ r and column ≥ c
minGteLte
(r, c)
min over row ≥ r and column ≤ c
minGteGte
(r, c)
min over row ≥ r and column ≥ c
Rectangle updates
rectAdd
(r1, c1, r2, c2, v)
Every cell of the rectangle += v
rectAssign
(r1, c1, r2, c2, v)
Every cell of the rectangle = v
rectChmax
(r1, c1, r2, c2, v)
Every cell = max(cell, v)
rectChmin
(r1, c1, r2, c2, v)
Every cell = min(cell, v)
2D hashing
rectHash
(r1, c1, r2, c2)
Hash of the rectangle: equal rectangles hash equal, wherever they are
rectsEqual
(r1, c1, r2, c2, r3, c3)
Is the rectangle equal to the same-size one whose top-left is (r3, c3)
hashAll
()
Hash of the whole grid