I am trying to find the largest substrings which are in both strings (minimum length of 3). So if I have:
String test1 = "testthatthisworks";
String test2 = "testthisthat";
I need the answer to be:
String[] Answer = ["test", "that", "this"];
My one problem is this needs to be as fast as possible. My current solution is to with a substring of length 3 from the smallest string, and then to see if this exists in the bigger string, if it does increment the size of the substring, if not move the substring along 1 point. The problem is that this is very slow as the strings grow in length. Does anyone have a solution to this problem?
Thanks
This is a modification of the
LCS algorithm, it will return all maximum length matchesof maximum size: