Sliding Window 3 Non fix size longest
int slow = 0;
int fast = 0;
[slow, fast]
while (fast < S.length()) {
// 1. add S[fast] into the sliding window
// 2. move slow to the correspoding position, update global min/max value;
while (window not staisfes the property) {
// 1. remove slow from the window
slow++;
}
// here slow is the lestmost position satisfying the property
// !! make sure you understand clearly about the termination of the while loop
// 1. update global longest. [slow, fast]
fast++;
}Q1 Find the longest substring withou duplciate characters
Q1.1 Given a string containing only lowercase English lettesr, how many of its substrings satisfy the requirement of 'containing duplicate characters'
Q2 Find the longest substring with at most k distinct characters.
Work with Stream
Q3 Desgin a counter class
Last updated