
The Longest Palindromic
Write a function that finds the longest palindromic substring of a given string. Try to be as efficient as possible!
If you find more than one substring, you should return the one that’s closer to the beginning.
Input: A text as a string.
Output: The longest palindromic substring.
Examples:
assert longest_palindromic("abc") == "a" assert longest_palindromic("abacada") == "aba" assert longest_palindromic("artrartrt") == "rtrartr" assert longest_palindromic("aaaaa") == "aaaaa"
Precondition:
1 < |text| ≤ 20
The text contains only ASCII characters.