WhiteBox
DSA
Start coding DSA Beyond LeetCode System Design AI Engineering White Room
RoadmapProblem sets
Quizzes Dan Ladder Contests Templates Graph Editor
Guides Library
Login Sign up
Sign up Log in

Workspaces

Start coding DSA Beyond LeetCode System Design AI Engineering White Room

DSA

Overview Roadmap Problem sets Quizzes Dan Ladder Contests Templates Graph Editor CP Guessr

Library

Library Guides

Community

Leaderboard Contributors Refer & Earn Cosmetics

Tools

Resume Reviewer Job Boards Changelog

Arrays and searching 0/120

DSA 0 of 360 problems solved
0%
Overview

Curriculum

    1. Hashing 0/11
    2. Two pointers 0/12
    3. Sliding window 0/21
    4. Prefix sums 0/29
      1. Prefix sum technique 0/13
      2. 2D prefix sums 0/6
      3. Difference arrays 0/10
    5. Binary search 0/20
    6. Heaps 0/11
    7. Greedy and intervals 0/9
    8. Linked lists 0/8
    9. Data structure design
  1. DSA
  2. / Arrays and searching

Prefix sums · 2 of 3

2D prefix sums

Build a table of block sums for a fixed grid and answer any rectangle sum with four reads.

1,152 words · 6 min read

Lesson Problems6 Reading3

Books1

  • Competitive Programmer’s Handbook, Section 9.1: Static array queries Page 85 draws the two-dimensional case as one rectangle with four marked corners and gives the formula in a single line. (opens in a new tab)

Links1

  • usaco.guide More on Prefix Sums Its 2D prefix sums section goes through a row-by-row version first and then solves Forest Queries on CSES with the same four-term formula. usaco.guide (opens in a new tab)

More links1

  • Range Sum Query 2D: Immutablealgo.monster (opens in a new tab)
Lesson: 2D prefix sums
Overview Roadmap Problem sets Log in