作者mqazz1 (無法顯示)
站內Prob_Solve
標題[問題] longest palindrome subsequence
時間Fri Nov 4 21:09:22 2011
A palindrome is a nonempty string over some alphabet that reads the same
forward and backward. Examples of palindromes are all strings of length 1,
civic, racecar, and aibohphobia (fear of palindromes)
input: A[1...n]
m[i+1,j-1] + 1 , if A[i] = A[j]
m[i,j] = max{ m[i,j-1], m[i+1,j] } , if A[i] != A[j]
請問這個遞迴式是甚麼意思?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.26.99
→ firejox:就是i到j的最長回文子序列 如果第i個不等於第j個 11/04 22:22
→ firejox:i到j的最長序列相當於 i到j-1 與 i+1到j的最長序列 11/04 22:23
→ firejox:反之如果第i個等於第j個 就是i+1到j-1的最長序列+1 11/04 22:25