We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.io.*;importjava.util.*;importjava.util.regex.Pattern;importjava.util.regex.Matcher;publicclassSolution{publicstaticvoidmain(String[]args){Scannerscanner=newScanner(System.in);Patternpattern=Pattern.compile("\\d{5} (C|CPP|JAVA)");// I couldn't put the entire string here due to the spam checker, but you get the pointintn=Integer.parseInt(scanner.nextLine());for(inti=0;i<n;i++){Matchermatcher=pattern.matcher(scanner.nextLine());System.out.println((matcher.matches())?"VALID":"INVALID");}}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
HackerRank Language
You are viewing a single comment's thread. Return to all comments →
java code