Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 6
- DEVELOPER.@gmail.com
- t+es+ter@GMAIL.COM
- T@bmail.com
- a@gmail.com.ru
- D.eveloper@Gmail.Com
- a+b@gmail.com.ru
- 5
- 1 a@gmail.com.ru
- 1 t+es+ter@GMAIL.COM
- 2 DEVELOPER.@gmail.com D.eveloper@Gmail.Com
- 1 a+b@gmail.com.ru
- 1 T@bmail.com
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Scanner;
- public class Mails {
- public static void main(String[] args) {
- Map<String, String> map = new HashMap<>();
- Scanner sc = new Scanner(System.in);
- int n = Integer.parseInt(sc.nextLine());
- for (int i = 0; i < n; i++) {
- String str1 = sc.nextLine();
- String str2 = str1.toLowerCase();
- String[] arr1 = str2.split("@");
- if (arr1[1].equals("gmail.com")) {
- str2 = arr1[0].replace(".", "") + "@gmail.com";
- if (str2.contains("+")) {
- String[] arr2 = str2.split("\+");
- str2 = arr2[0] + "@gmail.com";
- }
- }
- if (map.containsKey(str2)) {
- String value = map.get(str2);
- map.put(str2, value + " " + str1);
- }
- else {
- map.put(str2, str1);
- }
- }
- System.out.println(map.size());
- for (String value: map.values()) {
- int count = value.split(" ").length;
- System.out.println(count + " " + value);
- }
- }
- }
Add Comment
Please, Sign In to add comment