Guru Level
Implement the method minimumWindowLength that returns the length of the smallest substring containing all required characters.
Find the shortest contiguous substring of s that contains every character of t, including repeated characters.
The task is designed to test careful handling of edge cases, not only the most common input.
- Return
0if no valid window exists. - Return the length, not the substring text.
- Character frequency matters.
Example 1
Input
s (string) =
ADOBECODEBANCt (string) =
ABCReturns (int)
4Example 2
Input
s (string) =
at (string) =
aaReturns (int)
0Example 3
Input
s (string) =
abdabcat (string) =
abcReturns (int)
3Count required characters from t, expand the right side until valid, then shrink the left side while validity remains.
Ready to test your solutionRun Code checks your solution against the test cases.Shift + Enter to run