#C10622. Filter and Sort Colors
Filter and Sort Colors
Filter and Sort Colors
You are given a list of color names (strings) that may include empty strings. Your task is to process this list by performing the following operations:
- Filter out any empty strings.
- Remove duplicate color names.
- Sort the remaining color names in alphabetical order.
If, after filtering, there are no valid color names, you should output a single string: no colors
.
Input Format: The first line contains an integer \(n\) denoting the number of color entries. The following \(n\) lines each contain a color name. Note that a line may be empty.
Output Format: If there are valid colors, print them on a single line, separated by a single space, in alphabetical order. Otherwise, print no colors
.
inputFormat
The first line of input contains an integer \(n\), the number of color strings. Each of the next \(n\) lines contains one color string. A color string may be empty.
outputFormat
If there is at least one non-empty color, output the unique colors sorted in alphabetical order on a single line separated by spaces. Otherwise, output no colors
.
6
red
blue
red
green
blue
blue green red