Lexicographically Maximum Final Sequence

Company: IBM_5Dec

Difficulty: medium