You are given two strings A and B. You have to find smallest substring of A such that it contains all the letters of string B. The letters in both the strings can be any ASCII character.
Input constraints
\(1 \le T \le 1000\)
\(1 \le |A| \le 1000\) where A denotes the length of the string A.
\(1 \le |B| \le 1000\) where B denotes the length of the string B.
Input format
First line contains an integer, T,denoting the number of test cases.
First line in each test case contains a string, A.
Second line in each test case contains a string B.
Output format
Print the smallest substring of A such that it contains all the letters of string B. If there is no such substring, print 1. If there are multiple such substring, print the one which starts first. Answer for each test case should be in a new line.
1 ThisIsATestString TisT
ThisIsAT
The smallest substring that contains all the letter of string \(TisT\) is \(ThisIsAT\) which contains 8 letters.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor