All problems
Minimum Window Substring
Problem
Return the shortest substring of s that contains every character of t with the required multiplicities, or the empty string if none exists.
Grow a right pointer while counting characters and counting how many requirements are satisfied, then shrink from the left while the window stays valid. Track the smallest valid window seen.
Hint
The formed counter tracks how many distinct requirements are exactly satisfied.
Test cases
case 1
in: ["ADOBECODEBANC","ABC"]
expected: "BANC"
case 2
in: ["a","a"]
expected: "a"
case 3
in: ["a","aa"]
expected: ""
case 4
in: ["",""]
expected: ""
case 5
in: ["abc",""]
expected: ""
Starter codePython
def min_window_substring(s, t):
# Your code here
pass5 test cases · run your code against them in the editor