Skip to content

Latest commit

 

History

History
236 lines (159 loc) · 5.58 KB

longestPalindromeSubsequence.md

File metadata and controls

236 lines (159 loc) · 5.58 KB

Longest Common Subsequence

Problem :

Given an sequence X = <x1, x2,...,xm> and we wish to find a Z that maximum longest palindrome subsequence of X.

Recursive Formula :

Formula :

c[i,j] = if xi = yj and i > j > 0:
            c[i+1, j-1] + 2
            
         if xi != yj and i > j > 0:
            max(c[i,j-1], c[i+1,j])
            
         if i = j:
            1
         
         if i > j:
            0