Sliding window is one of my go-to techniques for optimizing problems that involve arrays or strings especially when you’re dealing with contiguous subarrays.
Instead of recalculating data from scratch for every window, you “slide” across the array by adding the new element and removing the old one.
It’s perfect for things like finding the max sum of k consecutive elements or checking substrings in a string for some condition.