← 返回 uber 的题目列表Longest Odd Length Palindrome
类型:online_judge
Given a string s, find the longest odd-length palindromic substring within it. The substring's length must be odd and among all such substrings, it should have the maximum length. You may assume the maximum length of s is 1000.
Input:
A string s of length [1, 1000] composed of lowercase English letters.
Output:
The longest odd-length palindromic substring.
Test cases:
Input: "babad"
Output: "bab"
Input: "cbbd"
Output: "b"
Input: "racecar"
Output: "racecar"
Input: ""
Output: ""
Input: "a"
Output: "a"
Example
Input
babad