Smallest window in a string containing all the characters of another string
Submissions: 860   Accuracy:

33.35%

  Difficulty: Easy   Marks: 2

Given a string S and text T. Output the smallest window in the string S having all characters of the text T. Both the string S and text T contains lowercase english alphabets.

Input Format:
First line of the input contains an integer T, denoting the number of test cases. Then T test case follows. Each test contains 2 lines having a string S and next line contains text T.

Output Format:
Output the smallest window of the string containing all the characters of the text. If such window doesn`t exist or this task can not be done then print -1.

Your Task:
This is a function problem. You only need to complete the function smallestWindow that returns smallest window of the string containing all the characters of the text. Else return "-1".

Constraints:
1 <= T <= 100
1 <= |N|, |X| <= 1000

Example:
Input:

2
timetopractice
toc
zoomlazapzo
oza

Output:
toprac
apzo

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Yash Kodesia
Author: Yash Kodesia 1


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.