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
Bug Slime

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: 9