-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day_28_Solution.java
39 lines (34 loc) · 1016 Bytes
/
Day_28_Solution.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
34
35
36
37
38
39
/**
* Title : Day_28_Solution.java
* Author : Tridib Samanta
* Created : 25-01-2020
* Link : https://www.hackerrank.com/challenges/30-regex-patterns/problem
**/
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Day_28_Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
Pattern p = Pattern.compile(".+@gmail\\.com");
Matcher m;
List<String> name = new ArrayList();
for(int a0 = 0; a0 < N; a0++){
String firstName = in.next();
String emailID = in.next();
m = p.matcher(emailID);
if (m.matches()) {
name.add(firstName);
}
}
Collections.sort(name);
for(String fname: name){
System.out.println(fname);
}
}
}