-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDay28.java
33 lines (26 loc) · 1006 Bytes
/
Day28.java
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
28
29
30
31
32
33
import java.io.*;
import java.util.*;
import java.util.regex.*;
public class Day28 {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(bufferedReader.readLine().trim());
String Regex=".+@gmail\\.com$";
List<String> list= new ArrayList();
Pattern pattern=Pattern.compile(Regex);
for (int NItr = 0; NItr < N; NItr++) {
String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
String firstName = firstMultipleInput[0];
String emailID = firstMultipleInput[1];
Matcher matcher=pattern.matcher(emailID);
if(matcher.find()){
list.add(firstName);
}
}
Collections.sort(list);
for(String names:list){
System.out.println(names);
}
bufferedReader.close();
}
}