Suppose the string length is N, For any i, j such that 0<=i<=N-1, 0<=j<=N-1, Ci is the character at index i, Cj is the character at index j L(i, j) = the max length of the subsequence palindrome in the substring Ci...Cj L(i, j) = 0 if i>j L(i, j) = 1 if i==j L(i, j) = 2 + L(i+1, j-1) if Ci == Cj L(i, j) = max {L(i, j-1), L(i+1, j)} if Ci != Cj L(0, N-1) will be the result you are looking for.