Longest Palindromic Subsequence

核心精神

Recurrence formula 會是這種形式:

if st[endIndex] == st[startIndex] 
    dp[startIndex][endIndex] = 2 + dp[startIndex + 1][endIndex - 1]
else 
    dp[startIndex][endIndex] = Math.max(dp[startIndex + 1][endIndex], dp[startIndex][endIndex - 1])

Last updated