
Medium
https://leetcode.com/problems/palindromic-substrings/
Given a string, your task is to count how many palindromic substrings in this string.
The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.
Example 1:
1 |
Input: "abc" |
2019.9.15 知道用马拉车方法做,照抄的第 5 题的马拉车算法,但是没能自己写出马拉车算法。
方法:
马拉车算法好厉害!
注意 ans += p[i]/2 (而不是 ans += p[i])
1 |
class (object): |
类似题目:
Longest Palindromic Substring
Longest Palindromic Subsequence
Palindromic Substrings




近期评论