1. CSDN机器学习知识图谱
2. 有趣的逻辑回归介绍
3. 机器学习资料整理
4. 最长回文子串-july
5. 最长回文子串~
# 最长回文子串
def manacher(s):
s = '#'+'#'.join(s)+'#'
rl, maxRight,pos,maxLen= [0]*len(s),0,0,0
for i in xrange(len(s)):
if i<maxRight:
rl[i] = min(rl[2*pos-i],maxRight-i)
else:
rl[i]=1
while i-rl[i]>=0 and i-rl[i]<len(s) and s[i-rl[i]]==s[i+rl[i]]:
rl[i]+=1
if rl[i]+i-1>maxRight:
maxRight=rl[i]+i-1
pos=i
maxLen=max(maxLen, rl[i])
return maxLen-1
print manacher('tattarrattat')