Challenge: Longest Common Substring
Let's write some code to find the longest common substring
We'll cover the following
Problem Statement
Given two strings, s1
and s2
, write a function that finds and returns the length of the longest substring of s2
in s1
(if any exist).
Input
two strings
Output
an integer
Sample Input
string s1 = "www.educative.io/explore";
string s2 = "educative.io/edpresso";
Sample Output
14
Coding Exercise
Take a close look and design a step-by-step algorithm before jumping on to the implementation. This problem is designed for your practice, so try to solve it on your own first. If you get stuck, you can always refer to the hint and solution provided in the code tab. Good Luck!
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.