316. Smallest Window Covering a Pattern
Print the length of the shortest contiguous stretch of s that contains every
character of t, counting repeats. Print 0 if there is no such stretch.
s = ADOBECODEBANC, t = ABC -> 4 (BANC)
Repeats matter: if t is aa then the window must hold two as.
Keep a map of how many of each character are still NEEDED, and a single counter of how many characters are still missing. Grow on the right, and once nothing is missing, shrink from the left while the window remains complete.
The single missing counter is what keeps this linear. Comparing two maps at every step would be correct and would cost far more.
Constraints - `1 ≤ length of s ≤ 200000` - `1 ≤ length of t ≤ 200000` - Both contain lowercase and uppercase letters only.
Input
The first line contains the string s.
The second line contains the string t.
Output
Print one integer, the length of the shortest covering stretch, or 0 if there is none.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.