desislava_topuzakova

01. Unique Usernames

May 27th, 2021
1,507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Demo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine());
  7.         LinkedHashSet<String> words = new LinkedHashSet<>();
  8.  
  9.         for (int count = 1; count <= n; count++) {
  10.             String word = scanner.nextLine();
  11.             words.add(word);
  12.         }
  13.  
  14.         //words.forEach(System.out::println);
  15.         for (String word : words) {
  16.             System.out.println(word);
  17.         }
  18.  
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment