1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/找出最长的超赞子字符串 [find-longest-awesome-substring].html
2022-03-29 12:43:11 +08:00

46 lines
1.3 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> 。请返回 <code>s</code> 中最长的 <strong>超赞子字符串</strong> 的长度。</p>
<p>「超赞子字符串」需满足满足下述两个条件:</p>
<ul>
<li>该字符串是 <code>s</code> 的一个非空子字符串</li>
<li>进行任意次数的字符交换后,该字符串可以变成一个回文字符串</li>
</ul>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>s = &quot;3242415&quot;
<strong>输出:</strong>5
<strong>解释:</strong>&quot;24241&quot; 是最长的超赞子字符串,交换其中的字符后,可以得到回文 &quot;24142&quot;
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>s = &quot;12345678&quot;
<strong>输出:</strong>1
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>s = &quot;213123&quot;
<strong>输出:</strong>6
<strong>解释:</strong>&quot;213123&quot; 是最长的超赞子字符串,交换其中的字符后,可以得到回文 &quot;231132&quot;
</pre>
<p><strong>示例 4</strong></p>
<pre><strong>输入:</strong>s = &quot;00&quot;
<strong>输出:</strong>2
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 10^5</code></li>
<li><code>s</code> 仅由数字组成</li>
</ul>