<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
longest	B-Algorithm
common	I-Algorithm
substring	I-Algorithm
of	O
two	O
or	O
more	O
strings	O
is	O
a	O
longest	O
string	O
that	O
is	O
a	O
substring	O
of	O
all	O
of	O
them	O
.	O
</s>
<s>
There	O
may	O
be	O
more	O
than	O
one	O
longest	B-Algorithm
common	I-Algorithm
substring	I-Algorithm
.	O
</s>
<s>
Applications	O
include	O
data	B-General_Concept
deduplication	I-General_Concept
and	O
plagiarism	O
detection	O
.	O
</s>
<s>
The	O
strings	O
"	O
ABABC	O
"	O
,	O
"	O
BABCA	O
"	O
and	O
"	O
ABCBA	O
"	O
have	O
only	O
one	O
longest	B-Algorithm
common	I-Algorithm
substring	I-Algorithm
,	O
viz	O
.	O
</s>
<s>
One	O
can	O
find	O
the	O
lengths	O
and	O
starting	O
positions	O
of	O
the	O
longest	B-Algorithm
common	I-Algorithm
substrings	I-Algorithm
of	O
and	O
in	O
time	O
with	O
the	O
help	O
of	O
a	O
generalized	B-Algorithm
suffix	I-Algorithm
tree	I-Algorithm
.	O
</s>
<s>
A	O
faster	O
algorithm	O
can	O
be	O
achieved	O
in	O
the	O
word	B-Application
RAM	I-Application
model	O
of	O
computation	O
if	O
the	O
size	O
of	O
the	O
input	O
alphabet	O
is	O
in	O
.	O
</s>
<s>
Solving	O
the	O
problem	O
by	O
dynamic	B-Algorithm
programming	I-Algorithm
costs	O
.	O
</s>
<s>
The	O
solutions	O
to	O
the	O
generalized	O
problem	O
take	O
space	O
and	O
·	O
...	O
·	O
time	O
with	O
dynamic	B-Algorithm
programming	I-Algorithm
and	O
take	O
time	O
with	O
a	O
generalized	B-Algorithm
suffix	I-Algorithm
tree	I-Algorithm
.	O
</s>
<s>
The	O
longest	B-Algorithm
common	I-Algorithm
substrings	I-Algorithm
of	O
a	O
set	O
of	O
strings	O
can	O
be	O
found	O
by	O
building	O
a	O
generalized	B-Algorithm
suffix	I-Algorithm
tree	I-Algorithm
for	O
the	O
strings	O
,	O
and	O
then	O
finding	O
the	O
deepest	O
internal	O
nodes	O
which	O
have	O
leaf	O
nodes	O
from	O
all	O
the	O
strings	O
in	O
the	O
subtree	O
below	O
it	O
.	O
</s>
<s>
The	O
following	O
pseudocode	O
finds	O
the	O
set	O
of	O
longest	B-Algorithm
common	I-Algorithm
substrings	I-Algorithm
between	O
two	O
strings	O
with	O
dynamic	B-Algorithm
programming	I-Algorithm
:	O
</s>
<s>
The	O
array	O
L	O
stores	O
the	O
longest	B-Algorithm
common	I-Algorithm
substring	I-Algorithm
of	O
the	O
prefixes	O
1	O
..	O
i	O
and	O
1	O
..	O
j	O
which	O
end	O
at	O
position	O
S[i],	O
T[j],	O
resp	O
.	O
</s>
<s>
The	O
variable	O
z	O
is	O
used	O
to	O
hold	O
the	O
length	O
of	O
the	O
longest	B-Algorithm
common	I-Algorithm
substring	I-Algorithm
found	O
so	O
far	O
.	O
</s>
<s>
The	O
set	O
ret	O
can	O
be	O
saved	O
efficiently	O
by	O
just	O
storing	O
the	O
index	O
i	O
,	O
which	O
is	O
the	O
last	O
character	O
of	O
the	O
longest	B-Algorithm
common	I-Algorithm
substring	I-Algorithm
(	O
of	O
size	O
z	O
)	O
instead	O
of	O
1	O
..	O
i	O
.	O
</s>
<s>
Thus	O
all	O
the	O
longest	B-Algorithm
common	I-Algorithm
substrings	I-Algorithm
would	O
be	O
,	O
for	O
each	O
i	O
in	O
ret	O
,	O
S[( ret[i]	O
-z	O
)	O
..	O
(	O
ret[i]	O
)	O
]	O
.	O
</s>
