#C9213. Remove Duplicate File Paths
Remove Duplicate File Paths
Remove Duplicate File Paths
You are given a list of file paths represented as strings. Your task is to remove any duplicate file paths while preserving the order of their first occurrence.
Input Format: The first line contains an integer n representing the number of file paths. Each of the following n lines contains a file path.
Output Format: Print the unique file paths, each on a new line, in the order of their first occurrence.
Example:
Input: 6 root.a root.b root.a root.c.d root.c.e root.c.d</p>Output: root.a root.b root.c.d root.c.e
The solution should employ an algorithm with a time complexity of \(O(n)\) on average, where \(n\) is the number of file paths.
inputFormat
The input is from stdin
. The first line contains an integer n indicating the number of file paths. The following n lines each contain one file path string.
outputFormat
The output should be written to stdout
. Print the unique file paths (one per line) in the order of their first appearance.
6
root.a
root.b
root.a
root.c.d
root.c.e
root.c.d
root.a
root.b
root.c.d
root.c.e
</p>