I was thinking on these lines

first idea is the
- the substring should start and end with the given words.
-  Keep information regarding occurances of the words

for example -
This is a test This is a programming test This is a programming test
in any language

this - 0,4,....
a - 2,6,....
test - 3,8
programming - 7,12.

Now, initially build one segment which contains all the words

0 - 7 (this segment contains all the words) and maintain a queue for that
0->2->3->4->6->7;

we have move this window by dequeuing the element and enqueuing

for example

now we will dequeue 0 identify what is its corresponding word - which
is 'this' and check where it is occuring next.


-- 
With love and regards,
Sairam Ravu
I M.Tech(CS)
Sri Sathya Sai Institute of Higher Learning
"To live life, you must think it, measure it, experiment with it,
dance it, paint it, draw it, and calculate it"

-- 


Reply via email to