Program | GCS.PAS, GCS.C, GCS.CPP) |
Your task is to write a program that computes the LENGTH of the longest common substring of two given strings. The substring does not have to be connected.
Examples: longest common string 1 string 2 substring length ------------------------------------------------------- abcabcabc aabbcc abbcc 5 aabcc 5 aabbc 5 belaljubljana belakrajina belajna 7 xxxyyyzzz aaabbbccc 0
Note that in the first example there are several different longest common substrings, but they all have the same length. You may assume all strings consist of lower-case letters only.Your program should work for fairly long strings (several hundred characters long).
INPUT:
3
ikarus
dedalus
onetwothreefour
fivesixseveneight
odnekdajlepesoljubljankeslovele
allepseodurskebiloninobene
OUTPUT:
3
3
13