标签:inpu substring ali level script leetcode 判断 暴力破解 mic
Description:
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:
输入: “babad” 输出: "bab" 注意:“aba”也是有效的答案
示例2:
输入:“cbbd” 输出: “bb”
方法一:暴力破解
首先,明确回文的概念。“回文串”是一个正读和反读都一样的字符串,比如“level”或者“noon”等等就是回文串。
遍历字符串s的每一个子串,并判断该子字符串是否为回文。
LeetCode 5: Longest Palindromic Substring
标签:inpu substring ali level script leetcode 判断 暴力破解 mic
原文地址:https://www.cnblogs.com/alpaca/p/9476395.html