Dsa
Sliding Window
Warm-up
Minimum Substring Length Containing Characters
Given two strings s and t, write a function to find the minimum length of a substring of s that contains all the characters in t (including duplicates).
If there is no such substring, return 0.
For example, for the input s = "ADOBECODEBANC" and t = "ABC", the output should be 4 because the minimum substring is "BANC".
Input Format:
- The first line contains the string s.
- The second line contains the string t.
Output Format:
- A single integer indicating the minimum length of a substring of s that contains all characters in t.
Example:
Input:
ADOBECODEBANC
ABC
Output:
4
Key concepts
sliding_windowstringsearch
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now