#C12120. Unique Sorted by Length
Unique Sorted by Length
Unique Sorted by Length
You are given a list of strings. Your task is to remove any duplicate strings and then sort the unique strings according to the following rules:
- First, by their length in ascending order.
- If two strings have the same length, sort them in lexicographical (alphabetical) order.
The input will be provided from stdin
and the output should be printed to stdout
. The first line of the input contains an integer n representing the number of strings. The next n lines each contain one string. Your program should output the sorted unique strings in a single line, separated by a space. If there are no strings, output an empty line.
Note: If any element is not a valid string, the program should throw an error. However, under normal contest conditions, all inputs will be valid strings.
inputFormat
The first line contains an integer n indicating the number of strings. The following n lines each contain one string.
outputFormat
Print the unique sorted strings on a single line separated by a single space. If there are no strings, output an empty line.
## sample6
pear
apple
orange
pear
banana
grape
pear apple grape banana orange