1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-25 17:50:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/从盒子中找出字典序最大的字符串 I [find-the-lexicographically-largest-string-from-the-box-i].html
2025-01-09 01:30:35 +08:00

53 lines
1.8 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>word</code> 和一个整数 <code>numFriends</code></p>
<p>Alice 正在为她的 <code>numFriends</code> 位朋友组织一个游戏。游戏分为多个回合,在每一回合中:</p>
<ul>
<li><code>word</code> 被分割成 <code>numFriends</code>&nbsp;<strong>非空&nbsp;</strong>字符串,且该分割方式与之前的任意回合所采用的都 <strong>不完全相同&nbsp;</strong></li>
<li>所有分割出的字符串都会被放入一个盒子中。</li>
</ul>
<p>在所有回合结束后,找出盒子中&nbsp;<span data-keyword="lexicographically-smaller-string">字典序最大的&nbsp;</span>字符串。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">word = "dbca", numFriends = 2</span></p>
<p><strong>输出:</strong> <span class="example-io">"dbc"</span></p>
<p><strong>解释:</strong>&nbsp;</p>
<p>所有可能的分割方式为:</p>
<ul>
<li><code>"d"</code><code>"bca"</code></li>
<li><code>"db"</code><code>"ca"</code></li>
<li><code>"dbc"</code><code>"a"</code></li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">word = "gggg", numFriends = 4</span></p>
<p><strong>输出:</strong> <span class="example-io">"g"</span></p>
<p><strong>解释:</strong>&nbsp;</p>
<p>唯一可能的分割方式为:<code>"g"</code>, <code>"g"</code>, <code>"g"</code>, 和 <code>"g"</code></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= word.length &lt;= 5&nbsp;* 10<sup>3</sup></code></li>
<li><code>word</code> 仅由小写英文字母组成。</li>
<li><code>1 &lt;= numFriends &lt;= word.length</code></li>
</ul>