All lessons

Sliding Window

7 min · C examples

Track a moving subarray window to answer range questions without restarting from scratch.

C · Sliding Window0/5 cleared

Enemy 1 of 5

A fixed-size window of length k slides across an array. Add the new element entering the window and subtract the one leaving — no need to resum the whole slice each time.

You
Invisible Heisenbug
Loading editor…
Sign up to fightThis one runs on our servers, so it needs a free account.

Stuck? Ask Rena

Your AI tutor that gives assistance.

Asking Rena in lessons is on Ultimate.