LC 5 Longest Palindromic Substring(M)
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example: Input: "babad" Output: "bab" Note: "aba" is also a valid answer. public String longestPalindrome(String s)
边界条件 如果字符串长度小于2,直接返回字符串
解题思路 DP
以每个字符为中心测试是不是回文,以及最大长度和起点。
PreviousLC 3 Longest Substring Without Repeating CharactersNextLC 17 Letter Combinations of a Phone Number(M)
Last updated
Was this helpful?