本文介绍了字符串中最长的回文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨 你能告诉我在字符串中找到最长的回文子字符串的最佳方法。 请解释。我有很多链接但是无法理解
Hi can you tell me the best way to find longest palindrome sub string in a string. please explain .i got lot of link but not able to understand
推荐答案这个问题有一个很好的讨论,这里有一个非常优化的算法: www.akalin.cx/longest-palindrome-linear-time [ ^ ] 它的工作原理是寻找来自的回文中心,这是一个如此明智的想法,它让你去:doh:!为什么我没想到这个?。 我留下它作为读者在C中实现它的练习 - 但它根本不需要任何树木! There is a good talk through of this problem, complete with a pretty much optimal algorithm here: www.akalin.cx/longest-palindrome-linear-time[^] It works by looking for palindromes from the centers, which is such a bright idea that it makes you go ":doh:! Why didn''t I think of that?". I leave it as an exercise for the reader to implement it in C - but it doesn''t need any trees at all!
更多推荐
字符串中最长的回文
发布评论