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 (English)/从盒子中找出字典序最大的字符串 I(English) [find-the-lexicographically-largest-string-from-the-box-i].html
2025-01-09 01:30:35 +08:00

51 lines
1.9 KiB
HTML

<p>You are given a string <code>word</code>, and an integer <code>numFriends</code>.</p>
<p>Alice is organizing a game for her <code>numFriends</code> friends. There are multiple rounds in the game, where in each round:</p>
<ul>
<li><code>word</code> is split into <code>numFriends</code> <strong>non-empty</strong> strings, such that no previous round has had the <strong>exact</strong> same split.</li>
<li>All the split words are put into a box.</li>
</ul>
<p>Find the <span data-keyword="lexicographically-smaller-string">lexicographically largest</span> string from the box after all the rounds are finished.</p>
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">word = &quot;dbca&quot;, numFriends = 2</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;dbc&quot;</span></p>
<p><strong>Explanation:</strong>&nbsp;</p>
<p>All possible splits are:</p>
<ul>
<li><code>&quot;d&quot;</code> and <code>&quot;bca&quot;</code>.</li>
<li><code>&quot;db&quot;</code> and <code>&quot;ca&quot;</code>.</li>
<li><code>&quot;dbc&quot;</code> and <code>&quot;a&quot;</code>.</li>
</ul>
</div>
<p><strong class="example">Example 2:</strong></p>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">word = &quot;gggg&quot;, numFriends = 4</span></p>
<p><strong>Output:</strong> <span class="example-io">&quot;g&quot;</span></p>
<p><strong>Explanation:</strong>&nbsp;</p>
<p>The only possible split is: <code>&quot;g&quot;</code>, <code>&quot;g&quot;</code>, <code>&quot;g&quot;</code>, and <code>&quot;g&quot;</code>.</p>
</div>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= word.length &lt;= 5&nbsp;* 10<sup>3</sup></code></li>
<li><code>word</code> consists only of lowercase English letters.</li>
<li><code>1 &lt;= numFriends &lt;= word.length</code></li>
</ul>