Longest palindrome in a string

By | September 30, 2015
Share the joy
  •  
  •  
  •  
  •  
  •  
  •  

The problem is from a post on mitbbs: http://www.mitbbs.com/article_t/CS/31217531.html

For example, longest palindrome in “animal” is “ana”, then return 3. Longest palindrome of “sfinished” is “sinis”, so return 5.

This is actually a dp problem for longest common substring. We just easily find the longest common substring between “animal” with “lamina”, that will be the result.

Check my code on github: link