Given a string, choose a lexicographically largest result under the problem’s allowed box-based selection rule.
You are given a string s. Think of the string as being placed in a box, and you must build a new string by selecting characters according to the rule described in the problem.
Your task is to return the lexicographically largest string that can be formed from the available characters under that rule.
In lexicographic order, a string is larger if at the first position where two strings differ, it has a larger character.
Construct the largest possible string according to the allowed operations and return it.
s.1 <= |s|.Example 1
Input
s = "bac"
Output
"c"
Explanation
Under a rule that allows selecting from the available box content, the lexicographically largest obtainable single-character result is c.
Example 2
Input
s = "zabc"
Output
"z"
Explanation
The largest character available dominates the result when the rule permits choosing one best character from the box.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.