2022-03-27 20:38:29 +08:00
|
|
|
|
<p>给定一个字符串 <code>s</code> ,请计算这个字符串中有多少个回文子字符串。</p>
|
|
|
|
|
|
|
|
|
|
<p>具有不同开始位置或结束位置的子串,即使是由相同的字符组成,也会被视作不同的子串。</p>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<strong>输入:</strong>s = "abc"
|
2022-03-27 20:38:29 +08:00
|
|
|
|
<strong>输出:</strong>3
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<strong>解释:</strong>三个回文子串: "a", "b", "c"
|
2022-03-27 20:38:29 +08:00
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
|
|
<p><strong>示例 2:</strong></p>
|
|
|
|
|
|
|
|
|
|
<pre>
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<strong>输入:</strong>s =<strong> </strong>"aaa"
|
2022-03-27 20:38:29 +08:00
|
|
|
|
<strong>输出:</strong>6
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<strong>解释:</strong>6个回文子串: "a", "a", "a", "aa", "aa", "aaa"</pre>
|
2022-03-27 20:38:29 +08:00
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
<li><code>1 <= s.length <= 1000</code></li>
|
|
|
|
|
<li><code>s</code> 由小写英文字母组成</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
2023-12-09 18:42:21 +08:00
|
|
|
|
<p><meta charset="UTF-8" />注意:本题与主站 70 题相同:<a href="https://leetcode-cn.com/problems/palindromic-substrings/">https://leetcode-cn.com/problems/palindromic-substrings/</a> </p>
|