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

Given a string and text output the smallest window in the string which covers all the characters present in the text. Both the string and text contains small case letters.
If such window doesn`t exist or this task can not be done then print -1.

Input:
First line contains T , the number of test cases and each test contains 2 lines having a string each  and  ( n is the main string and x is the text )

Output:
Output the smallest window of the string containing all the characters of the text.

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

Example:
Input:
2

timetopractice
toc
zoomlazapzo
oza

Output:
toprac
apzo

Disclaimer: This content belongs to geeksforgeeks, source: http://geeksforgeeks.org

rakesh

Leave a Reply

Your email address will not be published. Required fields are marked *

Skip to toolbar