Minimum Window Substring

Read the lesson → understand the pattern → then code. Tutor works offline (built-in teacher); optional Cursor/Gemini keys upgrade chat quality.

Topic refresher: Sliding Window — Live Range

Maintain [L,R] that satisfies a constraint; answer from length/sum/counts.

int L = 0;
for (int R = 0; R < n; R++) {
    // add s[R]
    while (/* invalid */) { /* remove s[L] */ L++; }
    // update answer
}
Sliding Window

Minimum Window Substring

Hard
LeetCode
3/6
HardSliding WindowLeetCode #76

Minimum Window Substring (Hard — stretch)

Need all chars of t covered. Expand until valid, shrink while valid, track best.

Examples

Example 1

Input

ADOBECODEBANC ABC

Output

BANC
Example 2

Input

a a

Output

a

Stuck? Take a nudge

C++17