Find the Longest Substring Shared by Two Strings solved by 153

March 18, 2014, 8:26 p.m. by Rosalind Team

In “Find the Longest Repeat in a String”, we encountered the Longest Repeat Problem, which could be solved using a suffix tree.

The second additional exercise that we will consider is below.

Longest Shared Substring Problem

Find the longest substring shared by two strings.

Given: Strings Text1 and Text2.

Return: The longest substring that occurs in both Text1 and Text2. (Multiple solutions may exist, in which case you may return any one.)

Sample Dataset

TCGGTAGATTGCGCCCACTC
AGGGGCTCGCAGTGTAAGAA

Sample Output

AGA

Extra Dataset

Please login to solve this problem.