AI engineering glossary · Data structures algorithms

What is sliding window?

Sliding window: A technique that maintains a contiguous range of a sequence and moves it forward one step at a time, updating the answer by adding the new item and removing the old one rather than recomputing. It brings many subarray problems to O(n).

Level: intermediateTopic: Data structures algorithms

Sliding window: an example

The highest total of any 3 consecutive days of sales in [4, 2, 7, 1, 9] is found by updating a running sum: 13, 10, 17.

Related terms

More Data structures algorithms terms

Where you learn it

Sliding window is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.