#K8431. Filter Unique File Paths by Extension

    ID: 36391 Type: Default 1000ms 256MiB

Filter Unique File Paths by Extension

Filter Unique File Paths by Extension

You are given a list of file paths and a file extension. Your task is to filter the file paths to return only those that have the specified extension. The paths should be output in the order they appear and should be unique (i.e. duplicate paths are removed).

Note: The filtering is case-sensitive, so '.txt' is different from '.Txt'.

Input Format: The first line contains an integer \(n\) denoting the number of file paths. The following \(n\) lines each contain a file path string. The last line contains the file extension to filter by.

Output Format: Output each qualifying file path on a separate line in the order they appear in the input. If there are no matching paths, output nothing.

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  • The first line contains an integer \(n\), the number of file paths.
  • The next \(n\) lines each contain a file path string.
  • The last line contains the file extension to filter by.

outputFormat

The output should be printed to standard output (stdout) where each matching, unique file path (that ends with the given extension) is printed on a new line. If there are no file paths matching the criteria, no output should be printed.

## sample
4
/home/user/file1.txt
/var/log/file2.log
/home/user/docs/report.pdf
/home/user/file1.txt
.txt
/home/user/file1.txt