The Longest Palindromic The Longest Palindromic
English FR RU

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 which is closer to the beginning.

Input: A text as a string.

Output: The longest palindromic substring.


longestPalindromic("artrartrt") == "rtrartr"
longestPalindromic("abacada") == "aba"
longestPalindromic("aaaa") == "aaaa"

Precondition: 1 < |text| ≤ 20
The text contains only ASCII characters.