Dynamic Programming21 sections · 916 units
Open in Course

Section Recap

What we learned

Look at what you can do now:

1.1. Build 1D (one-dimensional) and 2D prefix sum arrays

2.2. Answer any range sum query in O(1)O(1) time

3.3. Combine prefix sums with HashMaps for counting problems

4.4. Use prefix/suffix products when division isn't allowed

5.5.

Apply inclusion-exclusion for 2D rectangle queries This technique is a building block. You'll use it inside DP (dynamic programming) transitions, with binary search, and in string algorithms. But the core formula never changes: pref[r]pref[l1]pref[r] - pref[l-1].