File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -86,15 +86,18 @@ for r in range(len(r)):
8686// -------------------------
8787// V1 : while - while
8888// -------------------------
89+ // sliding window pattern
90+ // https://labuladong.online/algo/essential-technique/array-two-pointers-summary/#%E5%8E%9F%E5%9C%B0%E4%BF%AE%E6%94%B9
8991int left = 0 , right = 0 ;
90- while (right < s. size()) {
91- window. add(s[right]);
92+
93+ while (right < nums. size()) {
94+ // enlarge window
95+ window. addLast(nums[right]);
9296 right++ ;
93- // NOTE : most of the sliding windonw trick
94- // is dealing with "valid" conditions
95- // and how to cache some conditions for verfication
96- while (valid) {
97- window. remove(s[left]);
97+
98+ while (window needs shrink) {
99+ // lower window
100+ window. removeFirst(nums[left]);
98101 left++ ;
99102 }
100103}
You can’t perform that action at this time.
0 commit comments