Wednesday, January 9, 2013 Longest Palindromic Substring Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. Analysis: This is a DP problem. According to http://leetcode.com/2011/11/longest-palindromic-substring-part-i.html table[i][j] saves if the string start from i ends at j is the Palindromic string. Initial state: State Change: if s[i]==s[j], table[i][j]=table[i+1][j-1]; Source Code: class Solution { public:
Read full article from Yu's Coding Garden : leetcode Question 44: Longest Palindromic Substring
No comments:
Post a Comment