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

Sliding window 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`

#### Approach 1: Brute force

Iterating over `A`

one by one element to find max sum

```
```

#### Approach 2: Sliding Window

Iterating over `A`

window by window to find max sum

```
```