Sliding Window
edge cases
char note
iterate string:
add char
window formed
move left side char, move window
until window do not satisfy, repeat
two kinds of sliding window: 1) flexible length, usually max/min; 2) fixed length, usually find something.
flexible window
https://leetcode.com/problems/longest-substring-without-repeating-characters/description/
https://leetcode.com/problems/minimum-window-substring/description/
https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/description/
https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/description/
https://leetcode.com/problems/minimum-window-substring/description/
https://leetcode.com/problems/minimum-size-subarray-sum
https://leetcode.com/problems/subarray-product-less-than-k/description/
https://leetcode.com/problems/longest-repeating-character-replacement/description/
fixed window
https://leetcode.com/problems/substring-with-concatenation-of-all-words/description/
https://leetcode.com/problems/sliding-window-maximum/description/ https://leetcode.com/problems/sliding-window-median/description/ https://leetcode.com/problems/find-all-anagrams-in-a-string/description/ https://leetcode.com/problems/permutation-in-string/description/
https://leetcode.com/problems/k-empty-slots https://leetcode.com/problems/can-place-flowers/description/
Last updated