BugForge
DSA

Shortest Log Slice Covering All Codes

Hardsliding windowhash map 00:00

Return the shortest substring of s that contains every character of t (with multiplicity). If there are several, return the leftmost. Return "" if none.

Signature

minWindow(s: string, t: string) → string
Example 1
s = "ADOBECODEBANC"
t = "ABC"
output = "BANC"
'BANC'
Example 2
s = "a"
t = "aa"
output = ""
not enough a's → ''

Constraints

  • 1 ≤ |s|, |t| ≤ 10^5
Run checks the examples. Submit runs every hidden test (17, including large inputs that catch slow solutions).