63. Longest common substring

The longest common substring of two strings is, as you can probably guess, the longest substring that they have in common. For example, the longest common substring of the strings programming is easy and cramming is easiest before a test is ramming is eas.

Write a program that finds the longest common substring between two strings. If there are multiple longest common substrings with the same lengths, display one of them.

There are several approaches that you might take. The most obvious is to examine every possible substring of the first string and see whether it appears in the second string. You should be able to implement that approach.

The solution describes that approach and another one that demonstrates a useful dynamic programming technique.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset