滑動視窗 Sliding Window
20 題(16 題以此為主技法)
🎯 何時用
在連續子陣列/子字串中找「最長/最短/符合條件」的區段,且區段具單調性(擴張變壞、收縮變好)。
🧩 模板心法
右指針擴張、條件破壞時左指針收縮;維護視窗內統計(計數、和、distinct)。固定長度則同時推進兩端。
Easy 3 題
Medium 15 題
- #3Longest Substring Without Repeating Characters
- #424Longest Repeating Character Replacement
- #209Minimum Size Subarray Sum
- #438Find All Anagrams in a String
- #567Permutation in String
- #904Fruit Into Baskets
- #187Repeated DNA Sequences
- #658Find K Closest Elements
- #1343Number of Sub Arrays of Size K and Avg Greater than or Equal to Threshold
- #1456Maximum Number of Vowels in a Substring of Given Length
- #1838Frequency of The Most Frequent Element
- #1888Minimum Number of Flips to Make The Binary String Alternating
- #1423Maximum Points You Can Obtain From Cards
- #1658Minimum Operations to Reduce X to Zero
- #1871Jump Game VII