记录一下学习过程
滑动窗口学习(java)
滑动窗口算法框架
Map<Character, Integer> window = new HashMap<>();
int size = s.size();
int left = 0, right = 0;
while(right < size) {
//增大窗口
char c = s.charAt(right);
right++;
window.put(c, window.getOrDefault(c, 0) + 1);
while(window needs shrink) {
//缩小窗口
char d = s.charAt(left);
left++;
window.put(d, window.get(d) - 1);
}
}