Longest Common Subsequence

后端 未结 3 559
长发绾君心
长发绾君心 2021-01-02 10:53

Consider 2 sequences X[1..m] and Y[1..n]. The memoization algorithm would compute the LCS in time O(m*n). Is there any better algorithm to find out LCS wrt time? I guess mem

3条回答
  •  甜味超标
    2021-01-02 11:31

    If you know a priori an upper bound on the maximum size k you care about, you can force the LCS algorithm to exit early by adding an extra check in the inner loop. This means then when k << min(m,n) you can get small running times in spite of the fact you are doing LCS.

提交回复
热议问题