-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalid_pan_format.java
More file actions
31 lines (26 loc) · 911 Bytes
/
valid_pan_format.java
File metadata and controls
31 lines (26 loc) · 911 Bytes
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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
//solution to: https://www.hackerrank.com/challenges/valid-pan-format
public class valid_pan_format {
private static boolean isValidPAN(String s) {
String pattern = "([A-Z][A-Z][A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9][A-Z])";
boolean valid = s.matches(pattern);
return valid;
}
// Template Credit goes to www.hackerrank.com/kogupta
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
int i = Integer.parseInt(br.readLine());
for (int j = 0; j < i; j++) {
String s = br.readLine();
System.out.println(isValidPAN(s) ? "YES" : "NO");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}