The problem is as following:
Given 2 strings X and Y, I want to find the all (longest) common substrings, hence all substrings that appear in X and in Y and are maximal. for instance - if X = gttcatwg, Y = twgacgtt. return gtt and twg, not substrings of those (for instance gt).
It is Given that both share the same letters (with the same number of appearances) and both of same length.
O(N) algorithm.
- suggestion:
- build a generalized suffix tree. (Ukkonnen's algo)
- get all deepest (string wise) nodes that have leaves from both X and Y.
- from the above mentioned nodes remove all nodes that have suffix links in their subtree.
- it seems like it is not enough. an example: X = abcabc Y= bcaabc should return : bc, abc and bca but returns abc and bca.