Lexicographically Maximum Final Sequence

Company: Amazon_15_feb

Difficulty: medium