Longest Common Substring using Dynamic Programming

This problem can be solved using dynamic programming in O(len(X) * len(Y)), see this. In this article we are going to discuss about an efficient approach.

Find the Longest Common Substring using Binary search and Rolling Hash

Given two strings X and Y, the task is to find the length of the longest common substring. 

Examples:

Input: X = “w3wiki”, y = “GeeksQuiz” 
Output:
Explanation: The longest common substring is “Geeks” and is of length 5.

Input: X = “abcdxyz”, y = “xyzabcd” 
Output:
Explanation: The longest common substring is “abcd” and is of length 4.

Input: X = “zxabcdezy”, y = “yzabcdezx” 
Output:
Explanation: The longest common substring is “abcdez” and is of length 6.

Similar Reads

Longest Common Substring using Dynamic Programming:

This problem can be solved using dynamic programming in O(len(X) * len(Y)), see this. In this article we are going to discuss about an efficient approach....

Longest Common Substring using Binary Search and Rolling Hash

Pre-requisites:...