Data Structures19 sections · 729 units
Open in Course

Lessons from Shortest Subarray

Combined techniques

What did you learn?

1.1. Prefix sums turn subarray sum queries into two-point differences.

2.2. Monotonic deques can optimize searches over prefix values, not just array values.

3.3. The front removal differs from sliding window max: once an index gives a valid answer, it's consumed and removed.

4.4. Negative numbers complicate things. Without them, a simple two-pointer approach would work. You've solved a hard problem. If you understand it, you have a solid grasp of monotonic deques.