Minimum Window Substring

HardSliding Window
Next
StringSliding WindowHash Map

Find the smallest substring of s that contains every character of t, including duplicates (if t has two a's the window needs two a's). If several windows have the minimum length, report the leftmost one.

Input

Line 1: the string s. Line 2: the string t.

Output

Print the smallest window, or None if no window contains all characters of t.

Constraints

1 <= length of s, t <= 10^5 Both strings contain English letters.

Example 1
Input
ADOBECODEBANC
ABC
Output
BANC

BANC is the shortest window containing A, B and C.

Example 2
Input
a
aa
Output
None

There is only one a, but t needs two.

Hints

Minimum Window Substring - Hard Sliding Window Problem | Skill Shiksha