You are viewing a single comment's thread. Return to all comments →
Mine works. But I hate to import the libraries myself.
import java.io.*; import java.util.*; import java.util.Collections; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); String emailRegEx = ".+@gmail\\.com$"; Pattern pattern = Pattern.compile(emailRegEx); List<String> list = new ArrayList(); for (int i = 0; i < num; i++){ String name = scanner.next(); String email = scanner.next(); Matcher matcher = pattern.matcher(email); if (matcher.find()){ list.add(name); } } Collections.sort(list); for (String name : list){ System.out.println(name); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 28: RegEx, Patterns, and Intro to Databases
You are viewing a single comment's thread. Return to all comments →
Mine works. But I hate to import the libraries myself.