Sliding Window
Keep a contiguous range and update its summary as it moves, instead of rescanning it.
Sliding Window: Largest sum of 3 in a row
1 leaves and 7 enters, so the sum is 12. That beats the best so far.
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.