1243. Minimum Window Subsequence

HardDynamic ProgrammingString DP

Given strings s1 and s2, find the shortest contiguous substring of s1 that contains s2 as a subsequence. If several are equally short, return the leftmost one; if none exists, return the empty string. The input is JSON {s1, s2}.

Input: JSON {s1, s2}.

Output: String — the minimum window substring, or empty.

Examples

Example 1
Input: {"s1":"abcdebdde","s2":"bde"}
Output: bcde
Explanation: 'bcde' is the shortest window.
Example 2
Input: {"s1":"abc","s2":"d"}
Output: 
Explanation: No window exists.
Example 3
Input: {"s1":"a","s2":"a"}
Output: a
Explanation: Single character.

Constraints

Asked by

GoogleMeta
Solve this problem in the editor →