Interesting substring matching problem

Given a set of words: S = {“the”, “to”, “presentation”}
And a text T = “textmayrefertotherepresentationofwrittenlanguage”
Find the index of matching in text T from all words of S (one of permutations of S). It guarantees that the substring occurs exactly once in text.
Any idea how to solve this problem? (without bruteforce :()

This may help… Found this
Aho-Corasick implementaion on github :slight_smile:

try Finite State Automata…not sure if it will work…!!!

can u post a link to the problem page?