1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-04 15:01:40 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/插入一个字母的最大子序列数 [maximum-number-of-subsequences-after-one-inserting].html
2025-08-10 21:35:14 +08:00

55 lines
2.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个由大写英文字母组成的字符串 <code>s</code></p>
<p>你可以在字符串的&nbsp;<strong>任意&nbsp;</strong>位置(包括字符串的开头或结尾)<strong>最多插入一个&nbsp;</strong>大写英文字母。</p>
<p>返回在&nbsp;<strong>最多插入一个字母&nbsp;</strong>后,字符串中可以形成的 <code>"LCT"</code> 子序列的&nbsp;<strong>最大&nbsp;</strong>数量。</p>
<p><strong>子序列&nbsp;</strong>是从另一个字符串中删除某些字符(可以不删除)且不改变剩余字符顺序后得到的一个&nbsp;<strong>非空&nbsp;</strong>字符串。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">s = "LMCT"</span></p>
<p><strong>输出:</strong> <span class="example-io">2</span></p>
<p><strong>解释:</strong></p>
<p>可以在字符串 <code>s</code> 的开头插入一个 <code>"L"</code>,变为 <code>"LLMCT"</code>,其中包含 2 个子序列,分别位于下标&nbsp;[0, 3, 4] 和 [1, 3, 4]。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">s = "LCCT"</span></p>
<p><strong>输出:</strong> <span class="example-io">4</span></p>
<p><strong>解释:</strong></p>
<p>可以在字符串 <code>s</code> 的开头插入一个 <code>"L"</code>,变为 <code>"LLCCT"</code>,其中包含 4 个子序列,分别位于下标&nbsp;[0, 2, 4]、[0, 3, 4]、[1, 2, 4] 和 [1, 3, 4]。</p>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">s = "L"</span></p>
<p><strong>输出:</strong> <span class="example-io">0</span></p>
<p><strong>解释:</strong></p>
<p>插入一个字母无法获得子序列 <code>"LCT"</code>,结果为 0。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
<li><code>s</code> 仅由大写英文字母组成。</li>
</ul>