less than 1 minute read

Given two lowercase alphabet strings s0, and s1, return the length of their longest common substring.

Constraints

  • n, m ≤ 1000 where n and m are the lengths of s0 and s1

https://binarysearch.com/problems/Longest-Common-Substring

Examples

Example 1

Input

  • s0 = helloworld
  • s1 = worldpine

Output

  • answer = 5

Explanation

“world” is the longest common substring between the two strings.

Solution

Leave a comment