Fixed-Size Window
A window of size k. Add what enters, subtract what leaves, never re-add the middle.
Sliding Window: Largest sum of 3 in a row
2 leaves and 1 enters, so the sum is 7. The best stays at 8.
Cost
- Best
- O(n)
- Average
- O(n)
- Worst
- O(n)
- Space
- O(1)
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
Sliding Window covers these too, in the same run.