Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 20 lines (18 sloc) 0.359 kb
def LCS(S,T):
m = len(S)
n = len(T)
L = [[0]* (n+1) for i in xrange(m+1)]
LCS_SET = set()
longest = 0
for i in xrange(m):
for j in xrange(n):
if S[i] == T[j]:
v = L[i][j]+1
L[i+1][j+1] = v
if v > longest:
longest = v
LSC_SET = set()
if v == longest:
print LCS_SET
LCS("longest", "lonely")
Jump to Line
Something went wrong with that request. Please try again.