Let's consider the following problem: we have a set of strings (initially empty) and must handle two types of queries:
- Add new string to the set.
- For some input string do a check, if some string from the set occurs in the input string as a substring.
That's all. Of course, time/memory consuming should be as low as possible. Now I don't have an idea better than "Okay, let's use Aho-Corasick algo and each time, when we face query 1, let's destroy our old automaton and create a new one from scratch".
Thanks for your help.