6

SDE Sheet - Smallest window in a string containing all the characters of another...

 8 months ago
source link: https://www.geeksforgeeks.org/videos/sde-sheet-smallest-window-in-a-string-containing-all-the-characters-of-another-string/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Smallest window in a string containing all the characters of another string

December 28, 2023 |90 Views
SDE Sheet - Smallest window in a string containing all the characters of another string
SDE Sheet, GFG SDE Sheet, String
 Save  Share   Like
Description
Discussion

This video is part of Strings section under GFG SDE Sheet.

In this video, we are 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.

Example :

Input:
S = "timetopractice"
P = "toc"
Output: 
toprac

Explanation: "toprac" is the smallest substring in which "toc" can be found.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-

Article: https://www.geeksforgeeks.org/find-the-smallest-window-in-a-string-containing-all-characters-of-another-string/
Problem: https://practice.geeksforgeeks.org/problems/smallest-window-in-a-string-containing-all-the-characters-of-another-string-1587115621/1

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK