Hard · Strings

Min window substring

Given ASCII strings s and t, return the shortest substring of s that contains every character of t, counting repeats (the leftmost one if several are equally short), or "" if no substring does.

Examples

Example 1

s="ADOBECODEBANC", t="ABC"

Output: "BANC"

Example 2

s="aa", t="aa"

Output: "aa"

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Strings problems