TheKabeton

Untitled

Nov 21st, 2020
704
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def LCS_DYN(y, x):
  2.     L = matrix
  3.     LCS = []
  4.     x_i, y_i = len(x), len(y)
  5.     while x_i >= 0 and y_i >= 0:
  6.         if x[x_i - 1] == y[y_i - 1]:
  7.             LCS.append(x[x_i - 1])
  8.             x_i, y_i = x_i - 1, y_i - 1
  9.         elif L[x_i - 1][y_i - 1] == L[x_i][y_i]:
  10.             x_i -= 1
  11.             y_i -= 1
  12.         elif L[x_i - 1][y_i] > L[x_i][y_i - 1]:
  13.             x_i -= 1
  14.         else:
  15.             y_i -= 1
  16.     LCS.reverse()
  17.     return LCS
RAW Paste Data