Minimum Window Substring

IF
AlgoAxiomStaff Engineers
JSTS
Hard20 mins

Given two strings s and t, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "".

Examples

Input: s = "ADOBECODEBANC", t = "ABC"

Output: "BANC"

Explanation: The minimum window substring "BANC" contains 'A', 'B', and 'C' from string t.


Input: s = "a", t = "a"

Output: "a"

Explanation: The entire string s is the minimum window.


Input: s = "a", t = "aa"

Output: ""

Explanation: Both 'a's from t must be included in the window, but s only contains one 'a', so return an empty string.

Constraints

  • 1 <= s.length, t.length <= 10^5
  • s and t consist of uppercase and lowercase English letters.
Source: Two Pointers pattern — AlgoAxiom
JavaScript
Test Case 1
root = [1, 2, 3]
Test Case 2
root = [1, 2, 3, 4, 5]
Idle