Tristan's Collection of Interview Questions: The Longest Palindrome Substring (Manacher's algorithm)...

Please Visit: http://ift.tt/1ajReyV



Tristan's Collection of Interview Questions: The Longest Palindrome Substring (Manacher's algorithm)

Problem: Given a string, find a longest palindrome (Link->http://ift.tt/1lP2xZQ) substring.

Solution: We can use general suffix tree that stores the original string and its reverse, which is an O(N) algorithm. However, here we give a better one with less space overhead while still O(N) complexity. This algorithm is called Manacher's algorithm (Link->http://ift.tt/1pd7lau) . If we check a string from left to right, we can leverage the palindrome check we did previously. This is from the symmetry of palindrome.

http://ift.tt/1lP2yg8

http://ift.tt/1pd7laz



Tristan's Collection of Interview Questions: The Longest Palindrome Substring (Manacher's algorithm)







from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1pd7iLU

via LifeLong Community

No comments:

Post a Comment