Window Sliding is a method for iterating over a linear collection by maintaining a window range indices (group of consecutive elements) to satisfy the problem constraints

Window Sliding is an improvement over brute force iteration to reduce the time complexity

Let's see a specific example

The Maximum Subarray problem

Given an array A, write an algorithm to find the maximum sum of k consecutive elements in A

Brute force approach

Iterating over A one by one element to find max sum


Window sliding approach

Iterating over A window by window to find max sum