|
| 1 | +<h2><a href="https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-i/?envType=daily-question&envId=2025-06-04">3403. Find the Lexicographically Largest String From the Box I</a></h2><h3>Medium</h3><hr><p>You are given a string <code>word</code>, and an integer <code>numFriends</code>.</p> |
| 2 | + |
| 3 | +<p>Alice is organizing a game for her <code>numFriends</code> friends. There are multiple rounds in the game, where in each round:</p> |
| 4 | + |
| 5 | +<ul> |
| 6 | + <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> |
| 7 | + <li>All the split words are put into a box.</li> |
| 8 | +</ul> |
| 9 | + |
| 10 | +<p>Find the <span data-keyword="lexicographically-smaller-string">lexicographically largest</span> string from the box after all the rounds are finished.</p> |
| 11 | + |
| 12 | +<p> </p> |
| 13 | +<p><strong class="example">Example 1:</strong></p> |
| 14 | + |
| 15 | +<div class="example-block"> |
| 16 | +<p><strong>Input:</strong> <span class="example-io">word = "dbca", numFriends = 2</span></p> |
| 17 | + |
| 18 | +<p><strong>Output:</strong> <span class="example-io">"dbc"</span></p> |
| 19 | + |
| 20 | +<p><strong>Explanation:</strong> </p> |
| 21 | + |
| 22 | +<p>All possible splits are:</p> |
| 23 | + |
| 24 | +<ul> |
| 25 | + <li><code>"d"</code> and <code>"bca"</code>.</li> |
| 26 | + <li><code>"db"</code> and <code>"ca"</code>.</li> |
| 27 | + <li><code>"dbc"</code> and <code>"a"</code>.</li> |
| 28 | +</ul> |
| 29 | +</div> |
| 30 | + |
| 31 | +<p><strong class="example">Example 2:</strong></p> |
| 32 | + |
| 33 | +<div class="example-block"> |
| 34 | +<p><strong>Input:</strong> <span class="example-io">word = "gggg", numFriends = 4</span></p> |
| 35 | + |
| 36 | +<p><strong>Output:</strong> <span class="example-io">"g"</span></p> |
| 37 | + |
| 38 | +<p><strong>Explanation:</strong> </p> |
| 39 | + |
| 40 | +<p>The only possible split is: <code>"g"</code>, <code>"g"</code>, <code>"g"</code>, and <code>"g"</code>.</p> |
| 41 | +</div> |
| 42 | + |
| 43 | +<p> </p> |
| 44 | +<p><strong>Constraints:</strong></p> |
| 45 | + |
| 46 | +<ul> |
| 47 | + <li><code>1 <= word.length <= 5 * 10<sup>3</sup></code></li> |
| 48 | + <li><code>word</code> consists only of lowercase English letters.</li> |
| 49 | + <li><code>1 <= numFriends <= word.length</code></li> |
| 50 | +</ul> |
0 commit comments