#K38702. Lexicographically Smallest String
Lexicographically Smallest String
Lexicographically Smallest String
You are given a string s
. You can repeatedly move any character from the string to the end. Your task is to find the lexicographically smallest string that can be obtained by applying this operation any number of times.
This problem can be interpreted mathematically as follows: Let \( s \) be a sequence of characters. The lexicographically smallest string obtainable is equivalent to the string obtained by sorting all characters of \( s \) in ascending order, i.e. \( \text{answer} = \text{sorted}(s) \).
Note: Sorting means arranging characters from the smallest (according to their ASCII values) to the largest.
inputFormat
The input consists of a single line containing the string s
.
It is guaranteed that the string is non-empty and may contain spaces and other printable characters.
outputFormat
Output the lexicographically smallest string obtained by sorting all characters in s
in ascending order.
The result should be printed on a single line.
## samplebcda
abcd