sliding-window

Sliding Window

How to spot ?

  • Strings ,Arrays, Linkedlist

  • Contiguous sequence of elements ( Grouped sequentially )

  • Find Min,Max,Longest,Shortest,Contains

Java | C++ | Python3 | Detailed explanation | O(N) time - LeetCode Discuss

Fucking sliding window

Question variant

1. Fixed Length window

eg. max subArray of size K

2. Dynamic window

eg. smallest sum ≥ value S

3. Dynamic window with auxiliary data structure*

eg. Longest substring with no more than k distinct characters

*helper data structure such as hashset or hashmap

4. Permutations of a string

Last updated