Longest Palindromic Substring: Given a string S, find the longest palindromic substring in S. My first thought came up is reversing the string then find the longest common substring of S and S'. While there is obvious flaw in this algorithm. Can take a look of solution over here. http://leetcode.com/2011/11/longest-palindromic-substring-part-i.html http://leetcode.com/2011/11/longest-palindromic-substring-part-ii.html There is a O(n) solution over here which is very elegant and concise, while is a little bit hard to understand. Here is a good explanation in Chinese. Check it out. http:
Read full article from 喵喵~: Longest Palindromic Substring @Leetcode
No comments:
Post a Comment