链表
数
数组
滑动窗口(双向队列)
- 滑动窗口的最大值
- 最小覆盖子串
滑动窗口代码框架
详细过程戳这里:
void slidingWindow(string s, string t) {
unordered_map<char, int> need, window;
for (char c : t) need[c]++;
int left = 0, right = 0;
int valid = 0;
while (right < s.size()) {
char c = s[right];
right++;
...
printf("window: [%d, %d)\n", left, right);
while (window needs shrink) {
char d = s[left];
left++;
...
}
}
}
双指针
首位收缩问题
- 两数之和有序数组II:leetcode.cn/problems/tw…
- 盛最多的水:leetcode.cn/problems/co…
同起点
- 移动零:leetcode.cn/problems/mo…
回溯
动态规划
- 接雨水:leetcode.cn/problems/tr…