3403. Find the Lexicographically Largest String From the Box I Medium

@problem@discussion
#Two Pointers#String#Enumeration



1/**
2 * [3403] Find the Lexicographically Largest String From the Box I
3 *
4 * You are given a string word, and an integer numFriends.
5 * Alice is organizing a game for her numFriends friends. There are multiple rounds in the game, where in each round:
6 * 
7 * 	word is split into numFriends non-empty strings, such that no previous round has had the exact same split.
8 * 	All the split words are put into a box.
9 * 
10 * Find the <span data-keyword="lexicographically-smaller-string">lexicographically largest</span> string from the box after all the rounds are finished.
11 *  
12 * <strong class="example">Example 1:
13 * <div class="example-block">
14 * Input: <span class="example-io">word = "dbca", numFriends = 2</span>
15 * Output: <span class="example-io">"dbc"</span>
16 * Explanation: 
17 * All possible splits are:
18 * 
19 * 	"d" and "bca".
20 * 	"db" and "ca".
21 * 	"dbc" and "a".
22 * </div>
23 * <strong class="example">Example 2:
24 * <div class="example-block">
25 * Input: <span class="example-io">word = "gggg", numFriends = 4</span>
26 * Output: <span class="example-io">"g"</span>
27 * Explanation: 
28 * The only possible split is: "g", "g", "g", and "g".
29 * </div>
30 *  
31 * Constraints:
32 * 
33 * 	1 <= word.length <= 5 * 10^3
34 * 	word consists only of lowercase English letters.
35 * 	1 <= numFriends <= word.length
36 * 
37 */
38pub struct Solution {}
39
40// problem: https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-i/
41// discuss: https://leetcode.com/problems/find-the-lexicographically-largest-string-from-the-box-i/discuss/?currentPage=1&orderBy=most_votes&query=
42
43// submission codes start here
44
45impl Solution {
46    pub fn answer_string(word: String, num_friends: i32) -> String {
47        String::new()
48    }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55    use super::*;
56
57    #[test]
58    fn test_3403() {
59    }
60}
61


Back
© 2025 bowen.ge All Rights Reserved.