Find the shortest substring of one string that contains every character from another string, including multiplicities.
Given two strings s and t, return the shortest substring of s that contains every character from t with at least the same frequency.
If no such substring exists, return an empty string.
A substring is a contiguous segment of the original string. Characters are case-sensitive and must be matched exactly.
Search through s efficiently and identify the minimum-length valid window.
stBoth strings contain standard ASCII characters in the common LeetCode version of this problem.
s that contains all characters from t with required multiplicities.st must appear in the window at least as many times as it appears in t""Example 1
Input
s = "ADOBECODEBANC", t = "ABC"
Output
"BANC"
Explanation
"BANC" is the shortest substring of s containing A, B, and C.
Example 2
Input
s = "a", t = "a"
Output
"a"
Explanation
The only substring is valid.
Example 3
Input
s = "a", t = "aa"
Output
""
Explanation
s does not contain enough a characters to form a valid window.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.