Minimum Window Substring
hard · sliding window
Return the shortest contiguous substring of text containing every character of required with at least its required multiplicity. Ignore no characters: comparisons are case-sensitive. If shortest windows tie, choose the smallest starting index. Return '' if required is empty or no window exists. Strings have at most 500 characters.
Examples (JSON; null means Python None):
Input: {"text": "ADOBECODEBANC", "required": "ABC"}
Output: "BANC"
Input: {"text": "aa", "required": "aa"}
Output: "aa"
Starter code
def minimum_window(text: str, required: str) -> str:
"""Find the earliest minimum window covering a character multiset."""
pass
Loading editor…
Each test has a five-second execution limit. Your practice drafts and solved progress stay in this browser.
Return to the Python compiler