October 5th, 2013, 01:32 AM
Join Date: Oct 2013
Time spent in forums: 17 m 3 sec
Reputation Power: 0
Urgent Help(please Solve In C)
Given a string S, and a string T, find the length of the smallest substring of S which contains all the characters of T - in any order. If no such substring exists, print -1.
The first line consists of the string S.
The next line consists of a single integer Q, the number of strings "T" that you would query for in S.
Then follow Q lines, each consisting of a single string T.
Q lines, the answers to the Q queries.
1 <= |S| <= 100000
1 <= Q <= 100
1 <= |T| <= 1000
All characters in the input are lowercase 'a'-'z'.