Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 596 Bytes

File metadata and controls

20 lines (14 loc) · 596 Bytes

Longest Common Substring

Task:

Given multiple words, you need to find the longest string that is a substring of all words.

Input Format:

A string of words, separated by spaces. The string can also contain numbers.

Output Format:

A string, representing the longest common substring. If there are multiple longest common substrings, output the smallest one in alphabetical order.

Sample Input:

SoloLearn Learning LearningIsFun Learnable

Sample Output:

Learn

Explanation:

Learn is the longest common substring for the words SoloLearn Learning LearningIsFun Learnable.