Problem statement
Given a text s and a target t, return the shortest contiguous stretch of s that contains every character of t at least as many times as t holds it.
If no such stretch exists, return the empty string. A window is named by its two ends, both inclusive.
Examples
Inputs = "adobecodebanc", t = "abc"
Output"banc"
Several stretches cover abc, and banc is the shortest of them.
Inputs = "a", t = "aa"
Output""
The text holds one a and the target needs two, so no window ever covers it.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing