Longest common substring: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: undid a "bug-fix" as it broke the program and produced an incorrect result ("TES" instead of "TEXT").) |
(→Searching for smaller substrings of a in b: Trimming is not necessary in the C# implementation of the algorithm.) |
||
Line 80: | Line 80: | ||
for (int k = lenx - j; k > -1; k--) /*step through string lengths. */ |
for (int k = lenx - j; k > -1; k--) /*step through string lengths. */ |
||
{ |
{ |
||
string common = x.Substring(j, k |
string common = x.Substring(j, k); /*extract a common substring. */ |
||
if (y.IndexOf(common) > -1 && common.Length > output.Length) output = common; /*longest?*/ |
if (y.IndexOf(common) > -1 && common.Length > output.Length) output = common; /*longest?*/ |
||
} /*k*/ |
} /*k*/ |