deyanmalinov

01. Unique Usernames

Jun 1st, 2019
142
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package DPM;
  2. import java.util.LinkedHashSet;
  3. import java.util.Scanner;
  4. import java.util.Set;
  5.  
  6. public class Main {
  7.     public static void main(String[] args){
  8.         Scanner scan = new Scanner(System.in);
  9.         int num = Integer.parseInt(scan.nextLine());
  10.         Set<String> names = new LinkedHashSet<>();
  11.         for (int i = 0; i < num; i++) {
  12.             String name = scan.nextLine();
  13.             names.add(name);
  14.         }
  15.         for (String name : names) {
  16.             System.out.println(name);
  17.         }
  18.     }
  19. }
RAW Paste Data