I need to find the longest common substring of n strings and use the result in my project.
Is there any existing implementation/library in java which already does this?
Thanks for your replies in advance.
I need to find the longest common substring of n strings and use the result in my project.
Is there any existing implementation/library in java which already does this?
Thanks for your replies in advance.
Well you could try to extend the version of wikipedia (http://en.wikipedia.org/wiki/Longest_common_substring_problem) for n Strings by putting it into a loop which iterates over all your Strings.
What about concurrent-trees ?
It is a small (~100 KB) library available in Maven Central. The algorithm uses combination of Radix and Suffix Trees. Which is known to have a linear time complexity (wikipedia).
This page pretty much gives exactly what you want in quite a few languages.
We can use below code to identify longest common sub string of n Strings