Take a quick look at Maximum Sum in a Sliding Window of Length w. Let’s talk about a Sliding Window problem and how to solve it.
Let’s talk about a Sliding Window problem and how to solve it.
The Sliding Window approach is useful when you have a set of data (like a string or array) and you are looking for a continuous subset of the data. We create a window (which can be a subarray or substring) and move the window depending on a condition.
Consider the following problem: Write a function which accepts an array of integers and a number called w. The function should calculate the maximum sum of w consecutive elements in the array.