FAANG VO question

You are given a list of strings L, and many queries. For each query, you are given a string, and you want to see if this string is a contiguous substring of one of the strings in L.

Is there a solution better than bruce force (parsing all the strings separately for each query)?

I don't know if there's a way to manipulate a trie to solve this problem. The issue here is the "contiguous substring" isn't necessarily the start of one of the strings in L. It could be an inner substring, so I didn't think a trie would work here.

Comments (2)