Implement a function to find the longest palindromic substring in a string.
Define def longest_palindromic_substring(s):, where s is a string and the function returns the longest contiguous palindromic substring; return "" for empty input. For equal-length answers, return the one that appears first, such as "babad" producing "bab"; constraints are 0 <= len(s) <= 1000 and s contains printable characters.
def longest_palindromic_substring(s):