摘要: 原文地址:http://blog.csdn.net/v_july_v/article/details/6712171查找一个字符串中的最长回文字串,可以使用扩展法。从一个字符开始,向两边扩展,看看最多能到多长,使其保持为回文。具体而言,我们可以枚举中心位置,然后再在该位置上用扩展法,记录并更新得到的最长的回文长度,即为所求。代码如下:/** *find the longest palindrome in a string, n is the length of string s *Copyright(C) fairywell 2011 */ int LongestPalindrome... 阅读全文
posted @ 2013-09-21 11:48 xmuliushuo 阅读(320) 评论(0) 推荐(0)