#C5796. Lexicographically Smallest String
Lexicographically Smallest String
Lexicographically Smallest String
In this problem, you are given a string (S) of length (N) containing lowercase English letters. You are allowed to perform any number of swap operations (possibly zero). Your task is to determine the lexicographically smallest string that can be obtained by rearranging (i.e. sorting) the characters of (S).
For example, if (S = \texttt{cba}), the answer is (\texttt{abc}).
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer (T) denoting the number of test cases.
- Each of the next (T) lines contains an integer (N) and a string (S) separated by a space, where (N) is the length of (S).
outputFormat
For each test case, output a single line to standard output (stdout) containing the lexicographically smallest string that can be achieved by rearranging the characters of (S) in non-decreasing order.## sample
3
3 cba
5 geeks
4 dcba
abc
eegks
abcd
</p>