Lexicographically Smallest Encoded String

Company: Rippling_26july

Difficulty: medium