830. Longest common substring
Given two strings str1 and str2, find the length of their longest common substring.
A substring is a contiguous sequence of characters within a string.
Example 1:
Input: str1 = "abcde", str2 = "abfce"
Output: 2
Explanation: The longest common substring is "ab", which has a length of 2.
Example 2:
Input: str1 = "abcdxyz", str2 = "xyzabcd"
Output: 4
Explanation: The longest common substring is "abcd", which has a length of 4.
Now Your Turn!
Pick the correct output for the given inputInput: str1 = "abcdef", str2 = "ghijkl"
Still unsure what the problem is asking ?
Letās go through a few more examples, step by step, to make it clearer.
Constraints:
- n=str1.length
- m=str2.length
- 1<= n, m <=103
- str1 and str2 are in lowercase alphabet