Interesting substring matching problem

algorithm
string
substring

#1

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 :()


#2

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


#3

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


#4

can u post a link to the problem page?