@atul If we need to find the longest palindrome whether even or odd we can 
use DP.The recursion can look this:

           LP(i,j)  =  max( LP(i+1,j),LP(i,j-1)   if(string[i]!=string[j])
                          max( LP(i+1,j),LP(i,j-1),LP(i+1,j-1)+1 )  else
                         Note : Do LP(i+1,j-1)+1 only if it returns value 
equal to j-1.So that we can add adj characters also as they will be 
continuous

The time will be O(n^2) and space also O(n^2).You can optimize space to 
O(n).

Correct me if I am wrong.
@Lucifier I didnt understand ur algo

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/J8hZJllMTfgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to