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.
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int testedNumber = sc.nextInt();
sc.nextLine();
ArrayList<String> al = new ArrayList<>();
for(int i=0;i<testedNumber;i++){
al.add(sc.nextLine());
}
String regex = "[A-Z]{5}[0-9]{4}[A-Z]{1}";
Pattern p =Pattern.compile(regex);
boolean b=false;
for(int i=0;i<al.size();i++){
Matcher m=p.matcher(al.get(i));
b=m.matches();
if(b){
System.out.println("YES");
}
else {
System.out.println("NO");
}
}
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Valid PAN format
You are viewing a single comment's thread. Return to all comments →
For java 8
import java.io.; import java.util.; import java.util.regex.Matcher; import java.util.regex.Pattern;
public class Solution {
}