Question: A string is a palindrome if it reads the same forward and backward, for example 'racecar'. Given text, find and return the longest consecutive

A string is a palindrome if it reads the same forward and backward, for example 'racecar'. Given text, find and return the longest consecutive substring inside text that is a palindrome. If there exist multiple palindromes of the same largest possible length, return the leftmost one. text 'saippuakauppias' 'abaababaaabbabaababababaa' 'xxzxxracecar' 'xyxracecaryxy' Expected result 'saippuakauppias' 'aababababaa' 'racecar' 'racecar'
Step by Step Solution
There are 3 Steps involved in it
Python Function def longestPalindrometext if not text return ... View full answer
Get step-by-step solutions from verified subject matter experts
