Find the Shortest Non-Shared Substring of Two Strings solved by 225

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

In “Find the Longest Repeat in a String” and “Find the Longest Substring Shared by Two Strings”, we encountered two problems that could be solved using a suffix tree. A third such problem is shown below.

Shortest Non-Shared Substring Problem

Find the shortest substring of one string that does not appear in another string.

Given: Strings Text1 and Text2.

Return: The shortest substring of Text1 that does not appear in Text2. (Multiple solutions may exist, in which case you may return any one.)

Sample Dataset


Sample Output


Extra Datasets

Please login to solve this problem.