Removing duplicates and sorting

Report a typo

Write a program that reads a sequence of strings from the standard input and displays them in a lexicographic order without duplicates.

Try to write your solution using a set.

Input data format

The first line contains the size of a string sequence. Next lines contain strings.

Output data format

A sorted sequence of strings without duplicates. Each string must be in a new line.

Sample Input 1:

6
postgres
sqlite
oracle
mongodb
postgres
mssql

Sample Output 1:

mongodb
mssql
oracle
postgres
sqlite

Sample Input 2:

5
1
2
2
11
20

Sample Output 2:

1
11
2
20
Write a program in Java 17
class Main {
public static void main(String[] args) {
// put your code here
}
}
___

Create a free account to access the full topic