#C8866. Lexicographically Smallest Permutation
Lexicographically Smallest Permutation
Lexicographically Smallest Permutation
You are given a number of test cases. In each test case, you are given a string. Your task is to compute the lexicographically smallest permutation of the characters of the given string. In other words, sort the characters of the string in ascending order.
For each test case, output the result in the following format: Case #i: ans
, where i
represents the test case number (starting from 1) and ans
is the sorted string.
The lexicographical order is defined as the natural order of characters. The sorted string is obtained by rearranging the characters of the input string in increasing order.
Example:
For input string "hello", the lexicographically smallest permutation is "ehllo".
inputFormat
The input is read from standard input (stdin) and is structured as follows:
- The first line contains a single integer T, the number of test cases.
- Each of the following T lines contains a non-empty string for which you need to compute the answer.
outputFormat
For each test case, output a single line in the format:
Case #i: sorted_string
where i is the test case number (starting from 1) and sorted_string
is the sorted permutation of the input string. The output should be printed to standard output (stdout).
2
hello
algorithm
Case #1: ehllo
Case #2: aghilmort
</p>