Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
In lexicographical order, the elements to the left have higher priority than those that come after. Can you think of a strategy that incrementally builds the answer from left to right?