LCS Again!

3.8

5 votes
Binary search algorithm, String, Hard, Algorithms, Hash function, Hashing algorithm
Problem

Given two strings s and t consisting of only lowercase English alphabets, find the length of Longest Common Substring of the two strings. 

Input:
The first line contains a string s of length n.
The second line contains a string t of length m.

Output:
Output a single line denoting the length of Longest Common Substring of the two strings.

Constraints:

1n,m105

It is guaranteed that the strings s and t only contains lowercase English alphabets.
 

Sample Input
abcba
acab
Sample Output
2
Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

The longest common substring is "ab". Other common substrings are "a", "c" and "b".

Editor Image

?