Week 2 Review
Reinforce Kadane, sliding window, and prefix-sum thinking before week 3.
0 of 11 problems solved
Week 2 Review
Reinforce Kadane, sliding window, and prefix-sum thinking before week 3.
- •Can I tell Kadane apart from Sliding Window?
- •Do I know when to use a Set vs a frequency map?
- •Do I know when prefix sum beats a window?
Week two is where moving-window thinking starts to feel natural. Some problems want the biggest valid window. Some want the smallest valid window. Some want a fixed-size window. And one sneaky problem, Subarray Sum Equals K, is not really a sliding window at all. Review day is about learning to notice those differences early, before you write code that fights the problem instead of helping it.
The pattern choice matters as much as the implementation details.
- 1Ask whether the window size is fixed, growing, or shrinking.
- 2If the rule depends on duplicates or counts, think Set or frequency map.
- 3If the goal is best subarray without a literal window rule, ask whether Kadane fits better.
- 4If the problem asks for exact subarray sums with possible negatives, think prefix sum plus HashMap.
Treating every subarray problem like sliding window is a classic week-two trap. Some of them want prefix sums instead.