Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings
Back to syllabus

Sliding Window

4 chapters · 9 challenges · The Glass Canyon

Understand the idea, practise through play, then prove it in code. Choose your next quest below.

Visual introduction to this topic
Start here · 3 minute mental model

What is a sliding window?

A sliding window maintains information about one contiguous region while its boundaries move. Instead of recomputing the region from scratch, it updates only what entered and what left.

Think of a moving camera frame. The camera sees one part of a long parade. As it moves, one performer exits and another enters; everything in the middle stays known.

Expand, update, and shrink while keeping the window rule true.

Contiguous is the clue

Windows apply to neighboring values, characters, or events in one ordered stream.

Carry the summary

Update a sum, count, set, deque, or frequency map at each boundary move.

Shrink for validity

Variable windows contract until the required condition becomes true again.

What you will learn firstThe Sunlit Window

Move a sum without rebuilding it

Begin the guided lesson

Your chapter route

The Sunlit Window

Continue
Source reviewed

Built from authoritative material

This track is checked against the sources below. Visual traces still carry their own complete or guided coverage label, so unfinished explanations are not presented as complete executions.

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead