• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
July 08, 2022 |33.6K Views
Minimum Window Substring
  Share  2 Likes
Description
Discussion

Given two strings, string1 and string2, the task is to find the smallest substring in string1 containing all characters of string2 efficiently.

Examples:

Input: string = “this is a test string”, pattern = “tist” 
Output: Minimum window is “t stri” 
Explanation: “t stri” contains all the characters of pattern.

Input: string = “geeksforgeeks”, pattern = “ork” 
Output: Minimum window is “ksfor”

1- Generate all substrings of string1 (“this is a test string”) 
2- For each substring, check whether the substring contains all characters of string2 (“tist”) 
3- Finally, print the smallest substring containing all characters of string2.


Minimum Window Substring  : https://www.geeksforgeeks.org/find-the-smallest-window-in-a-string-containing-all-characters-of-another-string/

Read More