Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Sliding window solution in Clear category for The Longest Palindromic by altairjericho
def longest_palindromic(text):
for n in range(len(text),0,-1):
for i in range(len(text)-n+1):
word = text[i:i+n]
if word[::-1]==word: return word
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaa", "The A"
Sept. 30, 2018
Comments: