1. Window sliding technique:

Window Sliding Technique is a computational technique that aims to reduce the use of nested loops and replace it with a single loop, thereby reducing the time complexity.

Untitled

📌When can we use Sliding Window Technique:-

When the size of the window for computation is fixed throughout the complete nested loop.

📌Steps of using sliding window Technique: -

  1. Find the size of the window required
  2. Compute the result for 1st window, i.e. from the start of the data structure
  3. Then use a loop to slide the window by 1, and keep computing the result window by window.

📌Where can we use this : -