[問題] longest palindrome subsequence

看板Prob_Solve (計算數學 Problem Solving)作者 (無法顯示)時間13年前 (2011/11/04 21:09), 編輯推噓0(003)
留言3則, 1人參與, 最新討論串1/2 (看更多)
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

11/04 22:22, , 1F
就是i到j的最長回文子序列 如果第i個不等於第j個
11/04 22:22, 1F

11/04 22:23, , 2F
i到j的最長序列相當於 i到j-1 與 i+1到j的最長序列
11/04 22:23, 2F

11/04 22:25, , 3F
反之如果第i個等於第j個 就是i+1到j-1的最長序列+1
11/04 22:25, 3F
文章代碼(AID): #1Ei-G4j6 (Prob_Solve)
文章代碼(AID): #1Ei-G4j6 (Prob_Solve)