Longest Common Substring
Get startedজয় শ্রী রাম
🕉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.