Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Skill

Prefix Sums & Intervals

Answer range queries in O(1) after linear preprocessing and process interval data by sorting and sweeping.

Intermediate1 roadmap

4 objectives 6 steps about 115 min

Check what you know

The lessons are coming later. The knowledge check is ready now.

Take the knowledge check

This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.

Learning objectives

  • Build 1D and 2D prefix-sum arrays and answer range-sum queries in O(1) each.
  • Count subarrays with a target or divisible sum by combining prefix sums with a hash map, including inputs with negative numbers.
  • Apply difference arrays to batch range updates and compute point coverage counts.
  • Merge, insert and count overlapping intervals by sorting endpoints and sweeping, for example to find the minimum number of meeting rooms.

Lesson plan

6 steps, about 115 min · 0 of 5 lessons available so far

  1. Precompute Once, Query Fast Concept · 15 min · coming later
  2. Lab: Range Sums on Lists and Grids Lab · 20 min · coming later
  3. Subarray Sums with a Running Map Worked example · 25 min · coming later
  4. Difference Arrays for Batch Updates Worked example · 15 min · coming later
  5. Sweeping Through Intervals Worked example · 25 min · coming later
  6. Check: Ranges and Intervals Knowledge check · 8 questions

Practise it

From a booking log, find the busiest hour with a difference array, merge overlapping reservations, compute the minimum number of rooms, and count runs of daily balances summing to k; pass tests with negative values and touching intervals.

References

Hard prerequisites

Unlocks

On these roadmaps

Progress and evidence for this skill are shared across all of them.