This practice workspace is built for desktop. Open it on a larger screen to start solving.
Minimum Window Subsequence
Given strings s and t, find the minimum-length contiguous substring of s that contains all characters of t as a subsequence (in order). Return the substring, or "" if no such window exists.
Two-pointer approach: scan forward through s matching t left-to-right to find the end of a window, then scan backward from that end to tighten the start, then advance and repeat.
DP approach: dp[i][j] = the starting index in s where a subsequence ending at s[i-1] covers t[0..j-1].
Examples
Constraints
- 1 <= s.length <= 2 * 10^4
- 1 <= t.length <= 100
- s and t consist of lowercase English letters.
Preview Mode
This is a read-only preview of DSAMind's AI coaching. Sign up to get custom feedback on your own solution.
Your approach
- Pattern:Dynamic Programming
- Time:O(N)
- Space:O(1)
Complete approach — pattern and complexity both named.
Coach
What you got right
You correctly matched the sorted input requirement and implemented a linear-time scan using two pointers.
Where it diverged
No divergence detected. The code correctly aligns with the stated approach.
Next attempt: focus on
Try solving related sliding window problems to build familiarity with two-pointer variants.
Signals
No signals fired — clean run, you stayed in flow.