Longest Palindromic Substring. 最长回文子串.
一、题目
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example 1:
Input: “babad”
Output: “bab”
Note: “aba” is also a valid answer.
Example 2:
Input: “cbbd”
Output: “bb”
题目翻译:
给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为1000。
二、解题方案
方案1:暴力法
思路: 选出所有子字符串可能的开始和结束位置,并验证是否为符合回文。
代码实现:
(略)