这里是一道问题(6.7 ch6)来自Vazirani的算法书,与经典的找到最长回文串问题略有不同。我该如何解决这个问题?
A subsequence is palindromic if it is the same whether read left to right or right to left. For instance, the sequence
A,C,G,T,G,T,C,A,A,A,A,T,C,G
has many palindromic subsequences, including
A,C,G,C,A
andA,A,A,A
(on the other hand, the subsequenceA,C,T
is not palindromic). Devise an algorithm that takes a sequencex[1 ...n]
and returns the (length of the) longest palindromic subsequence. Its running time should beO(n^2)
abcxxba
有abcba
作为最长的回文子序列 - 这是否正确?因为在这种情况下,被接受的答案对我来说是错误的... - Floris