Code Room
CodingHardcod-g155
Subject StringsLevel Senior–Staff~35 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given strings s and t, return the shortest contiguous substring of s that contains every character of t including multiplicities (e.g. if t has two 'a's, the window must too). If no such window exists, return the empty string. If there are multiple shortest windows, any one of them is acceptable but the reference returns the leftmost. For example, the minimum window of "ABC" inside "ADOBECODEBANC" is "BANC". s and t can each be up to 10^5 characters; aim for O(len(s)) time.

Implement
min_window(s: str, t: str) → str
Examples
in["ADOBECODEBANC","ABC"]out"BANC"
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.