Given two strings. Find the smallest window in the first string consisting of all the characters of the second string.
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 (the first string) and next line contains a string P (the second string).
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.
You don't need to read input or print anything. Your task is to complete the function smallestWindow() which takes two string S and P as inputs and returns the smallest window in string S having all the characters of the string P. In case there are multiple such windows of same length, return the one with the least starting index. Return "-1" in case there's no such window present.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(1).
1 <= T <= 100
1 <= |S|, |P| <= 1000
Testcase 1: toprac is the smallest subset in which toc can be found.
Testcase 2: To find oza in the zoomlazapzo the smallest subset is apzo.
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.