Dec 29, 2008

How to find longest repeated substring

How to find longest repeated substring
Find longest common substring between str and str, arr[i][j]=arr[i-1][j-1]+1,if(str[i]==str1[j])
arr[i][j]=0 if(str[i]!=str1[j])
note, we should the ignore diagonal of the arr which is the str itself
The complexity is O(N^2)
Or use suffix tree which is O(n), not easy to code

No comments:

Post a Comment