Your question is Longest Palindrome. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A Sumo Logic backend service receives a compact log fragment as a string. Return its longest contiguous substring that is a palindrome, meaning it reads identically from left to right and right to left.
If multiple palindromic substrings have the maximum length, return the one with the smallest starting index.
Implement longest_palindrome(s).
s, a string containing lowercase English letters.s.A palindrome must be contiguous. For example, "aba" is valid within "caba", but "aa" formed from non-adjacent characters is not a substring.
def longest_palindrome(s):