Problem Statement
Given two strings A and B. We need to find the smallest substring of A that has all the characters in B. If there is no such string, then the answer will be an empty string.
Example:
A = "abcd"B = "bd"
Output: "bcd"
Explanation:
Here's all the substrings of string "abcd""a""b""c""d""ab""bc""cd""abc""bcd""abcd"
Here, we can clearly see that there are two substrings of A that have all the characters in string B and those are "bcd" and "abcd". The smaller one is "bcd"...
Published on July 21, 2022 12:16