input: Write a Python function to find the longest palindromic substring in a given string.
  assert longest_palindrome("babad") == "bab" or longest_palindrome("babad") == "aba"
  assert longest_palindrome("cbbd") == "bb"
  assert longest_palindrome("a") == "a"
  assert longest_palindrome("ac") == "a" or longest_palindrome("ac") == "c"
  assert longest_palindrome("forgeeksskeegfor") == "geeksskeeg"
output: def longest_palindrome(s: str) -> str:
      if len(s) == 0:
          return ""
      
      def expand_from_center(left: int, right: int) -> str:
          while left >= 0 and right < len(s) and s[left] == s[right]:
              left -= 1
              right += 1
          return s[left + 1:right]
      
      longest = ""
      for i in range(len(s)):
          # Odd length palindromes
          odd_palindrome = expand_from_center(i, i)
          if len(odd_palindrome) > len(longest):
              longest = odd_palindrome
          # Even length palindromes
          even_palindrome = expand_from_center(i, i + 1)
          if len(even_palindrome) > len(longest):
              longest = even_palindrome
      
      return longest