Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class ClothingSupply {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int N = Integer.parseInt(scanner.nextLine());
- List<String> Items = new ArrayList<>(N);
- TreeMap<String, Integer> ItemsMap = new TreeMap<>();
- for (int i = 0; i < N; i++) {
- Items.add(scanner.nextLine());
- }
- for (int i = 0; i < Items.size(); i++) {
- ItemsMap.put(Items.get(i), Collections.frequency(Items, Items.get(i)));
- }
- ItemsMap.entrySet().forEach(entry -> {
- String isEven;
- if (entry.getValue() % 2 == 0) {
- isEven = "Yes";
- } else isEven = "No";
- System.out.println(entry.getKey() + " " + entry.getValue() + " " + (isEven));
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement