File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,37 @@ for 狀態1 in 狀態1的所有取值:
125125-- -
126126
127127# ### Sliding Window
128-
128+ 維護一個窗口, 不斷滑動
129+ ```c++
130+ void slidingWindow(string s, string t){
131+ unordered map < char,int > need, window;
132+ for (char c:t) need[c++ ]
133+ int left = 0 , right = 0
134+ int valid = 0
135+
136+ while (right < s.size()){
137+ // c是將移入窗口的字符
138+ char c = s[right]
139+ // 右移窗口
140+ right++
141+ // 進行窗口內數據的一系列更新
142+ // ...
143+
144+ /*** 用來debug 輸出位置 ***/
145+ printf(" window: [%d , %d )\n " ,left,right)
146+ /************************/
147+
148+ // 判斷左側窗口是否收縮
149+ while (window needs shrink){
150+ // d是將移出窗口的字符
151+ // 左移窗口
152+ left++
153+ // 進行窗口內數據的一系列更新
154+ // ...
155+ }
156+ }
157+ }
158+ ```
129159| No. | Title | Solution | Difficulty | Time | Space | Topic |
130160| ---- - | :---- - :| :-------- :| ------------ | ------ | ------ - | ------ - |
131161| 0209 | [Minimum Size Subarray Sum](https:// leetcode.com/ problems/ minimum- size- subarray- sum / ) | [Go](https:// github.com/ kimi0230/ LeetcodeGolang/ tree/ master/ Leetcode/ 0209. Minimum- Size- Subarray- Sum) | Medium | O(n^ 2 ) / O(n) / O(nlog n) | O(1 ) / O(1 ) / O(n) | Sliding Window |
You can’t perform that action at this time.
0 commit comments