Find smallest substring

Given two strings string1 and string2, find the smallest substring in string1 containing all characters of string2 in O(n). You need to return the output substring.

Note : The characters of string2 need not to be present in same order in string1. That is, we need a substring which contains all characters of string2 irrespective of the order.

Return null if no substring with all characters is present.

Input format :

Line 1 : String 1

Line 2 : String 2

Sample Input 1 :
Looks for minimum string
Sample Output 1 :
mum s

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem