mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
49 lines
1.8 KiB
HTML
49 lines
1.8 KiB
HTML
|
<p>You are given a string <code>word</code>. A letter <code>c</code> is called <strong>special</strong> if it appears <strong>both</strong> in lowercase and uppercase in <code>word</code>, and <strong>every</strong> lowercase occurrence of <code>c</code> appears before the <strong>first</strong> uppercase occurrence of <code>c</code>.</p>
|
||
|
|
||
|
<p>Return the number of<em> </em><strong>special</strong> letters<em> </em>in<em> </em><code>word</code>.</p>
|
||
|
|
||
|
<p> </p>
|
||
|
<p><strong class="example">Example 1:</strong></p>
|
||
|
|
||
|
<div class="example-block">
|
||
|
<p><strong>Input:</strong> <span class="example-io">word = "aaAbcBC"</span></p>
|
||
|
|
||
|
<p><strong>Output:</strong> <span class="example-io">3</span></p>
|
||
|
|
||
|
<p><strong>Explanation:</strong></p>
|
||
|
|
||
|
<p>The special characters are <code>'a'</code>, <code>'b'</code>, and <code>'c'</code>.</p>
|
||
|
</div>
|
||
|
|
||
|
<p><strong class="example">Example 2:</strong></p>
|
||
|
|
||
|
<div class="example-block">
|
||
|
<p><strong>Input:</strong> <span class="example-io">word = "abc"</span></p>
|
||
|
|
||
|
<p><strong>Output:</strong> <span class="example-io">0</span></p>
|
||
|
|
||
|
<p><strong>Explanation:</strong></p>
|
||
|
|
||
|
<p>There are no special characters in <code>word</code>.</p>
|
||
|
</div>
|
||
|
|
||
|
<p><strong class="example">Example 3:</strong></p>
|
||
|
|
||
|
<div class="example-block">
|
||
|
<p><strong>Input:</strong> <span class="example-io">word = "AbBCab"</span></p>
|
||
|
|
||
|
<p><strong>Output:</strong> <span class="example-io">0</span></p>
|
||
|
|
||
|
<p><strong>Explanation:</strong></p>
|
||
|
|
||
|
<p>There are no special characters in <code>word</code>.</p>
|
||
|
</div>
|
||
|
|
||
|
<p> </p>
|
||
|
<p><strong>Constraints:</strong></p>
|
||
|
|
||
|
<ul>
|
||
|
<li><code>1 <= word.length <= 2 * 10<sup>5</sup></code></li>
|
||
|
<li><code>word</code> consists of only lowercase and uppercase English letters.</li>
|
||
|
</ul>
|