-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
27 lines (24 loc) · 798 Bytes
/
Solution.java
File metadata and controls
27 lines (24 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Solution {
private static final Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
String regEx = ".+@gmail\\.[a-z]+";
List<String> names = new ArrayList<>();
for (int i = 0; i < n; i++) {
String firstName = sc.next();
String eMail = sc.next();
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(eMail);
if (m.find()) names.add(firstName);
}
Collections.sort(names);
names.forEach(System.out::println);
sc.close();
}
}