Longest substring in a large set of strings

Posted by user1516492 on Stack Overflow See other posts from Stack Overflow or by user1516492
Published on 2012-07-11T03:13:03Z Indexed on 2012/07/11 3:15 UTC
Read the original article Hit count: 94

Filed under:

I have a huge fixed library of text strings, and a frequently changing input string s. I need to find the longest matching substring from any string in the library to s, starting from the beginning of string s, in minimal time. In a perfect world, I would also return the next longest match from the library, and the next best, and so on. This is not the longest common string problem - I'm not looking for the longest common string for all the strings in the library... I just need a pairwise best substring between s and each string in the vast library as fast as possible.

© Stack Overflow or respective owner

Related posts about c