#K83352. Remove Duplicate Files
Remove Duplicate Files
Remove Duplicate Files
Given a string containing file names separated by commas, your task is to remove any duplicate file names, trim extra spaces from each name, and then output the unique file names in lexicographical (alphabetical) order. The file names should be separated by a comma and a space in the output.
For example, if the input is:
fileA.txt, fileB.txt, fileA.txt, fileC.txt, fileB.txt, fileD.txt
the correct output would be:
fileA.txt, fileB.txt, fileC.txt, fileD.txt
Pay attention to extra spaces that may appear around file names.
inputFormat
The input consists of a single line read from standard input (stdin
) containing file names separated by commas. File names may include extra leading or trailing whitespace.
outputFormat
Output a single line to standard output (stdout
) containing the unique file names sorted in lexicographical order. The file names should be separated by a comma and a space.
fileA.txt, fileB.txt, fileA.txt, fileC.txt, fileB.txt, fileD.txt
fileA.txt, fileB.txt, fileC.txt, fileD.txt