Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 50s1 days 16 hours 1 minutes 50 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 50s1 days 16 hours 1 minutes 50 seconds.

Sign in to watch this lesson
Advanced - Data Structures and Range Queries · 4:47
A sparse table precomputes the answer for every window whose length is a power of two, level by level, in O(n log n) time and memory. For idempotent operations such as min, max and gcd, any range is covered by two overlapping blocks, so a query is O(1); sums need a greedy split into disjoint power-of-two blocks and cost O(log n). The table is for static data only: one update forces a rebuild.