Classic example
Input
s = "ADOBECODEBANC", t = "ABC"
Output
"BANC"
The smallest substring of s that contains 'A', 'B', and 'C' is "BANC".
Full lesson preview
Find the smallest substring of s that contains all characters of t (including duplicates) using a sliding-window and hashmap.
Problem statement
Task
Examples
Input
s = "ADOBECODEBANC", t = "ABC"
Output
"BANC"
The smallest substring of s that contains 'A', 'B', and 'C' is "BANC".
Input format
Output format
Constraints
Samples
Input
s = "a", t = "a"
Output
"a"
Single character match.