algorythms
Sliding Window
LC #76Hard

Minimum Window Substring

Sliding Window
AmazonGoogleMetaBloombergLinkedIn

Problem

Find the minimum window in string s which will contain all characters of string t.

stringsliding-windowhash-map

Constraints

  • 1 ≤ s.length, t.length ≤ 10⁵
  • s and t consist of uppercase and lowercase English letters
  • Answer is guaranteed to exist if not empty string

Example

Inputs = "ADOBECODEBANC", t = "ABC"
Output"BANC"
Why

Minimum window containing A, B, C is "BANC" (indices 9–12)

Hints — reveal one at a time