You are viewing a single comment's thread. Return to all comments →
That's why I haven't used regex ;)
Check this out:
public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int n = stdin.nextInt(); String[] allData = new String[n*2]; List<String> nameList = new ArrayList<>(); for(int i = 0; i < allData.length; i++) { allData[i] = stdin.next(); if(i % 2 == 1 && allData[i].substring(allData[i].length()-10).equals("@gmail.com")) nameList.add(allData[i-1]); } stdin.close(); String[] names = new String[nameList.size()]; names = nameList.toArray(names); Arrays.sort(names); for(String x : names) System.out.println(x); }
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 →
That's why I haven't used regex ;)
Check this out: