Question bankPricingSign in

Minimum Window Substring

Sliding WindowMedium1:30

Given two strings s and t, find the minimum window substring of s that contains all characters of t (including duplicates). If no such window exists, return an empty string.

For example, given s = "ADOBECODEBANC" and t = "ABC", the output is "BANC" because it is the smallest substring of s that contains A, B, and C.

Explain your approach, how you track when the window satisfies the requirement, and analyze complexity.

How to approach it

  • Hint 1

    Use a variable-size sliding window. Expand right to include more characters, shrink left to minimize the window.

  • Hint 2

    Maintain a frequency map of characters needed from t. Track how many required characters have been satisfied.

  • Hint 3

    When all characters are satisfied, try shrinking from the left to find the minimum valid window.

Ready to answer it out loud?

Record your answer in 1:30 and Preptile scores it 1–10 with specifics — what landed, what you skipped, and what to say next time.

Practising needs an invite code. Join the waitlist and we’ll send you one.