Advertisement
Hey_Donny

ClothingSupply

Sep 26th, 2022
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class ClothingSupply {
  4. public static void main(String[] args) {
  5.  
  6.  
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int N = Integer.parseInt(scanner.nextLine());
  10.  
  11. List<String> Items = new ArrayList<>(N);
  12.  
  13. TreeMap<String, Integer> ItemsMap = new TreeMap<>();
  14.  
  15. for (int i = 0; i < N; i++) {
  16. Items.add(scanner.nextLine());
  17. }
  18.  
  19. for (int i = 0; i < Items.size(); i++) {
  20. ItemsMap.put(Items.get(i), Collections.frequency(Items, Items.get(i)));
  21. }
  22.  
  23. ItemsMap.entrySet().forEach(entry -> {
  24. String isEven;
  25. if (entry.getValue() % 2 == 0) {
  26. isEven = "Yes";
  27. } else isEven = "No";
  28. System.out.println(entry.getKey() + " " + entry.getValue() + " " + (isEven));
  29. });
  30.  
  31. }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement