Classic example
Input
s = "ADOBECODEBANC", t = "ABC"
Output
"BANC"
"BANC" is the shortest substring of s that contains 'A','B','C'.
Full lesson preview
Find the smallest substring of s that contains all characters of t (including multiplicity) using sliding window frequency counts.
Problem statement
Task
Examples
Input
s = "ADOBECODEBANC", t = "ABC"
Output
"BANC"
"BANC" is the shortest substring of s that contains 'A','B','C'.
Input format
Output format
Constraints
Samples
Input
s = "a", t = "a"
Output
"a"
The single character matches.