mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 15:31:43 +08:00
update
This commit is contained in:
57
leetcode/problem/number-of-wonderful-substrings.html
Normal file
57
leetcode/problem/number-of-wonderful-substrings.html
Normal file
@@ -0,0 +1,57 @@
|
||||
<p>A <strong>wonderful</strong> string is a string where <strong>at most one</strong> letter appears an <strong>odd</strong> number of times.</p>
|
||||
|
||||
|
||||
|
||||
<ul>
|
||||
|
||||
<li>For example, <code>"ccjjc"</code> and <code>"abab"</code> are wonderful, but <code>"ab"</code> is not.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<p>Given a string <code>word</code> that consists of the first ten lowercase English letters (<code>'a'</code> through <code>'j'</code>), return <em>the <strong>number of wonderful non-empty substrings</strong> in </em><code>word</code><em>. If the same substring appears multiple times in </em><code>word</code><em>, then count <strong>each occurrence</strong> separately.</em></p>
|
||||
|
||||
|
||||
|
||||
<p>A <strong>substring</strong> is a contiguous sequence of characters in a string.</p>
|
||||
|
||||
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
|
||||
|
||||
<pre>
|
||||
|
||||
<strong>Input:</strong> word = "aba"
|
||||
|
||||
<strong>Output:</strong> 4
|
||||
|
||||
<strong>Explanation:</strong> The four wonderful substrings are underlined below:
|
||||
|
||||
- "<u><strong>a</strong></u>ba" -> "a"
|
||||
|
||||
- "a<u><strong>b</strong></u>a" -> "b"
|
||||
|
||||
- "ab<u><strong>a</strong></u>" -> "a"
|
||||
|
||||
- "<u><strong>aba</strong></u>" -> "aba"
|
||||
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
|
||||
|
||||
<pre>
|
||||
|
||||
<strong>Input:</strong> word = "aabb"
|
||||
|
||||
<strong>Output:</strong> 9
|
||||
|
||||
<strong>Explanation:</strong> The nine wonderful substrings are underlined below:
|
Reference in New Issue
Block a user