Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Minimum Window Substring Match

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Minimum Window Substring Match. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given two strings s and t, return the smallest substring of s that contains every character of t, including duplicates. If no such substring exists, return an empty string. The input is case-sensitive, and the output must be the minimum-length valid window.

Constraints

  • 1 <= len(s) <= 10^5
  • 1 <= len(t) <= 10^5
  • s and t consist of English letters
  • The answer is unique if it exists

Function Signature

def min_window(s, t):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output