Segment Tree with Lazy Propagation
Range query problems appear everywhere in competitive programming and production systems alike. You might need to find the sum of elements in a subarray, locate the minimum value in a range, or…
Read more →Range query problems appear everywhere in competitive programming and production systems alike. You might need to find the sum of elements in a subarray, locate the minimum value in a range, or…
Read more →Consider a common scenario: you have an array of a million integers representing sensor readings, and you need to repeatedly answer questions like ‘what’s the sum of readings between index 50,000 and…
Read more →Consider building a collaborative text editor where users can undo to any previous state. Or a database that answers queries like ‘what was the sum of values in range [l, r] at timestamp T?’ Or a…
Read more →Consider a game engine tracking damage values across a 1000×1000 tile map. Players frequently query rectangular regions to calculate area-of-effect damage totals. With naive iteration, each query…
Read more →