Given two strings s and t, return the shortest substring of s that contains every character of t, including duplicates, at least as many times as it appears in t. Return an empty string if no such substring exists.
s = "ADOBECODEBANC", t = "ABC""BANC"s = "a", t = "aa"""Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →A window — a contiguous subarray or substring — expands and shrinks as it moves across the input, so you track a running condition instead of recomputing it from scratch for every possible window.
Read the full Sliding Window guide →
Original problem on LeetCode ↗