Loading...
Loading...
Loading...
Two codes are given. Find the longest string that appears in both codes as one unbroken piece (a substring). Print its length.
Example
Input
orderbook ledgerbook
Output
6
The shared run is erbook.
Try the problem first. Open one hint at a time.
Let dp[i][j] be the length of the shared run that ends at letter i of one code and letter j of the other.
A mismatch resets the cell to 0. Track the largest cell seen.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor