Longest Palindromic Substring

Jun 11, 2016


```python def long_sub(s): rs=s[-1::-1] len_s = len(s) start = 0 rt=s[0:1] pt=”” curMax=1 while start < len_s: index = curMax while start + index <= len_s: pt=s[start:start+index] if pt in rs: index += 1 else: break if index > curMax: curMax=index-1 rt=s[start:start+index-1] start += 1 return rt

#long_sub(“a”) #long_sub(“abcbaabcbc”)