
Hi everyone,
I hope you all are doing good. Day 12 of my DSA series is Minimum Window Substring. It is the last and toughest stop in our sliding window run, but if you followed the last two days, you already know every move it needs.
The problem
You get two strings, s and t. Return the smallest substring of s that contains every character of t, including duplicates, or an empty string if there is none. It is LeetCode problem 76, rated hard.
Quick summary
- Think of it in two phases: grow the window on the right until it is valid, then shrink from the left while it stays valid.
- Keep one missing counter plus a need count from t. Extra characters simply go negative, which is what lets you shrink safely.
- Brute force checks every substring and times out. The sliding window runs in O(m + n) time with O(1) space using a 128 slot ASCII array.
- Store the best start and length, and slice only once at the end, so the solution stays truly linear.
- Common slips: ignoring duplicates in t, comparing full maps every step, and returning a leftover window when no valid one was found.
Solutions in Java, Python and Rust, test cases and real world uses are in the full post.
Thats all for now. Share it with a friend who is preparing for interviews.
Read the complete article: DSA Series Day 12: Minimum Window Substring in Java, Python and Rust

Blurt.blog
Discord
Komentarze