Alice is hosting an exciting word game for her friends! Here's how it works:
Given a string word and an integer numFriends, Alice runs multiple rounds where each round splits the word into exactly numFriends non-empty substrings. The key rule: no two rounds can have the identical split pattern.
After each round, all the split substrings go into a magical box. Your mission is to find the lexicographically largest string that ends up in the box after all possible rounds are completed.
Lexicographic Order: String a is lexicographically smaller than string b if at the first differing position, a has a character that appears earlier in the alphabet than b. If one string is a prefix of another, the shorter one is lexicographically smaller.
Example: With word="abc" and numFriends=2, possible splits are: ["a","bc"], ["ab","c"]. The box contains {"a", "bc", "ab", "c"}, so the lexicographically largest is "c".
Input & Output
Constraints
- 1 โค word.length โค 100
- 1 โค numFriends โค word.length
- word consists of lowercase English letters only
- The number of possible splits can be exponential