Longest Common Substring

Back to Edit Distance

The longest string that is a contiguous substring of two or more strings. Unlike LCS (subsequence), this requires characters to be consecutive. Can be solved with DP in O(mn) time or with suffix trees/arrays in O(n + m) time.

algorithms string-algorithms longest-common-substring