dsa10 min read
Longest Common Substring — DP, Rolling Hash, and Suffix Array Approaches
Find the longest contiguous substring shared by two strings. The DP solution is O(n*m), binary search plus rolling hash gives O((n+m) log min(n,m)) expected, and suffix array plus LCP achieves O((n+m) log(n+m)).
Read →