Deviopath › JavaScript

Minimum Window Substring

Hard · Strings

Write a function minWindow that returns the shortest substring of s that contains every character of t, including duplicates (if t has two "a", the window needs at least two "a").

If several windows have the same shortest length, return the one that starts first. If there is no such window, return an empty string. t is never empty. Letters are case-sensitive.

Next: LRU Cache