Grokking the Coding Interview: Patterns for Coding Questions
0% completed
Solution: Problem Challenge 3: Smallest Window containing Substring
Problem Statement
Given a string and a pattern, find the smallest substring in the given string which has all the character occurrences of the given pattern.
Example 1:
Input: String="aabdec", Pattern="abc"
Output: "abdec"
Explanation: The smallest substring having all characters of the pattern is "abdec"
Example 2:
Input: String="aabdec", Pattern="abac"
Output: "aabdec"
Explanation: The smallest substring having all characters occurrences of the pattern is "aabdec"
Example 3:
Input: String="abdbca", Pattern="abc"
.....
.....
.....
Like the course? Get enrolled and start learning!
A
Alan Ross
· 4 years ago
I don't understand the purpose of minLength? like it is the length of the entire string + 1, why is it called minLength? There's no explanation as to why it's called that and what it's used for.
Show 2 replies