Given two strings s1 and s2. Find the smallest window in the string s1 consisting of all the characters(including duplicates) of the string s2. return empty string in case no such window is present.
If there are multiple such windows of the same length, return the one with the least starting index.
Note: All characters are in lowercase letters.
Example 1
Input: s1 = "timetopractice", s2 = "toc"
Output: "toprac"
Explanation: "toprac" is the smallest substring in which "toc" can be found.
Example 2
Input: s1 = "zoomlazapzo", s2 = "oza"
Output: "apzo"
Explanation: "apzo" is the smallest substring in which "oza" can be found.
Example 3
Input: s1 = "zoom", s2 = "zooe"
Output: ""
Explanation: No window is present containing all characters of s2.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
timetopractice toc
toprac
zoomlazapzo oza
apzo
zoom zooe
''