F5 BIG-IP telemetry can contain compact identifiers and event fragments whose mirrored structure may indicate repeated or malformed data. Given a string, find its longest palindromic substring efficiently.
Return the substring itself. If multiple longest palindromic substrings exist, return the one with the smallest starting index. A substring must use consecutive characters, and matching is case-sensitive.
Implement longest_palindrome(s), where s is a string containing lowercase English letters. Return a string containing the longest contiguous substring that reads identically forward and backward. Return "" when s is empty.
For the hard version, design an algorithm with O(n) time and O(n) auxiliary space. Do not treat a subsequence as a valid answer.
def longest_palindrome(s):