Longest Common Substring
-
Algorithms and Data Structures: TheAlgorist.com
-
System Design: www.System.Design
-
Low Level Design: LowLevelDesign.io
-
Frontend Engineering: FrontendEngineering.io
জয় শ্রী রাম
🕉
Problem Statement:
Given two strings find length of the longest common substring.Solution:
If we keep the template discussed in 2-Strings DP in mind, this problem very easily transforms to: for all substrings in the two given strings, find the Longest Common SUFFIX. Why and How ? If the given two strings are str1 = "hackathoncode" and str2 = "marathonsprint", the longest common substring is "athon" which is the longest common SUFFIX for the substrings "hackathon" and "marathon".Java Code:
Login to Access Content
Python Code:
Login to Access Content
One of my goals is to make you very comfortable with bottom-up tabulation approach of solving Dynamic Programming. I hope you are getting the hang of it by now.
Instructor:
![](https://thealgoristsblob.blob.core.windows.net/thealgoristsimages/instagram_logo.png)
![](https://thealgoristsblob.blob.core.windows.net/thealgoristsimages/youtube_logo.png)
![](https://thealgoristsblob.blob.core.windows.net/thealgoristsimages/linkedin_logo.png)