Problem
Submissions
Debug

Problem: Find the Lexicographically Largest String From Box II

Statement

You are given a string, word, and an integer numFriends, representing the number of friends participating in a game organized by Alice.

The game consists of multiple rounds, and in each round:

  • The string word is split into exactly numFriends non-empty substrings.

  • The split must be unique; no previous round has produced the same sequence of splits.

  • All resulting substrings from the split are placed into a box.

When all rounds are over and all possible unique splits have been performed, determine the lexicographically largest string among all the substrings in the box.

A string aa is considered lexicographically larger than a string bb if:

  • At the first position where aa and bb differ, the character in aa comes later than the corresponding character in bb in the alphabet.

  • If aa is a prefix of bb, the longer string is considered larger.

Constraints:

  • 1≤1 \leq word.length ≤103\leq 10^3

  • word consists only of lowercase English letters.

  • 1≤1 \leq numFriends ≤\leq word.length

Problem
Submissions
Debug

Problem: Find the Lexicographically Largest String From Box II

Statement

You are given a string, word, and an integer numFriends, representing the number of friends participating in a game organized by Alice.

The game consists of multiple rounds, and in each round:

  • The string word is split into exactly numFriends non-empty substrings.

  • The split must be unique; no previous round has produced the same sequence of splits.

  • All resulting substrings from the split are placed into a box.

When all rounds are over and all possible unique splits have been performed, determine the lexicographically largest string among all the substrings in the box.

A string aa is considered lexicographically larger than a string bb if:

  • At the first position where aa and bb differ, the character in aa comes later than the corresponding character in bb in the alphabet.

  • If aa is a prefix of bb, the longer string is considered larger.

Constraints:

  • 1≤1 \leq word.length ≤103\leq 10^3

  • word consists only of lowercase English letters.

  • 1≤1 \leq numFriends ≤\leq word.length