Concept
A window of elements slides along an array, growing on the right and shrinking on the left, keeping a running summary. It finds the best contiguous span in O(n) rather than checking every start and end.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Sliding window doing its job.
def longest_unique_substring(s):
last = {}
start = best = 0
for end, ch in enumerate(s):
if ch in last and last[ch] >= start:
start = last[ch] + 1
last[ch] = end
best = max(best, end - start + 1)
return best
longest_unique_substring("abcabcbb") # 3Recomputing the window's summary from scratch each time it moves. The whole gain comes from updating the count or sum incrementally as one element enters and one leaves.
Your roadmap puts these before Sliding window, unless you already know them.
Once a session shows you understand Sliding window, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Sliding window.