1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/重构字符串 [reorganize-string].html

29 lines
682 B
HTML
Raw Normal View History

2022-03-27 20:46:41 +08:00
<p>给定一个字符串&nbsp;<code>s</code>&nbsp;,检查是否能重新排布其中的字母,使得两相邻的字符不同。</p>
<p>返回<em> <code>s</code>&nbsp;的任意可能的重新排列。若不可行,返回空字符串&nbsp;<code>""</code></em>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>示例&nbsp;1:</strong></p>
<pre>
<strong>输入:</strong> s = "aab"
<strong>输出:</strong> "aba"
</pre>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> s = "aaab"
<strong>输出:</strong> ""
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 500</code></li>
<li><code>s</code> 只包含小写字母</li>
</ul>