265. Minimum Window Subsequence (Length)

HardStringString

Given strings s and t, return the length of the minimum contiguous substring (window) of s such that t is a subsequence of that window. If there is no such window, return 0. If multiple windows have the same minimum length, the length is unique anyway. Input: '"s", "t"'.

Input: '"s", "t"'.

Output: Integer — minimum window length or 0.

Examples

Example 1
Input: "abcdebdde", "bde"
Output: 4
Explanation: 'bcde' is the shortest window containing 'bde' as a subsequence.
Example 2
Input: "abc", "abc"
Output: 3
Explanation: Whole string.
Example 3
Input: "abc", "d"
Output: 0
Explanation: No window.

Constraints

Asked by

GoogleMeta
Solve this problem in the editor →