• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
September 30, 2024 |180 Views

PROBLEM OF THE DAY : 24/09/2024 | Smallest window in a string containing all the characters of another string

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Sliding-window but also build up problem-solving skills.

Given two strings s and p. Find the smallest window in the string s consisting of all the characters(including duplicates) of the string p Return "-1" in case there is no such window present. In case there are multiple such windows of same length, return the one with the least starting index.
Note : All characters are in Lowercase alphabets. 

Examples:

Input: s = "timetopractice", p = "toc" Output: toprac Explanation: "toprac" is the smallest substring in which "toc" can be found.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/smallest-window-in-a-string-containing-all-the-characters-of-another-string-1587115621/1