字符串中最长的回文 [英] Longest palindrome in a string

查看:97
本文介绍了字符串中最长的回文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




你能告诉我在字符串中找到最长的回文子字符串的最佳方法。

请解释。我有很多链接但是无法理解

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

推荐答案

这个问题有一个很好的讨论,这里有一个非常优化的算法:

http://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:
http://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!


这篇关于字符串中最长的回文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆