mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
38 lines
1.3 KiB
HTML
38 lines
1.3 KiB
HTML
<p>给你一个字符串 <code>s</code> ,请找出满足每个字符最多出现两次的最长子字符串,并返回该<span data-keyword="substring">子字符串</span>的<strong> 最大 </strong>长度。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong class="example">示例 1:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">s = "bcbbbcba"</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">4</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p>以下子字符串长度为 4,并且每个字符最多出现两次:<code>"bcbb<u>bcba</u>"</code>。</p>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 2:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">s = "aaaa"</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">2</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p>以下子字符串长度为 2,并且每个字符最多出现两次:<code>"<u>aa</u>aa"</code>。</p>
|
||
</div>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul><!-- 字符串 s 的长度在 2 到 100 之间 -->
|
||
<li><code>2 <= s.length <= 100</code></li>
|
||
<!-- 字符串 s 仅包含小写英文字母 -->
|
||
<li><code>s</code> 仅由小写英文字母组成。</li>
|
||
</ul>
|