-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPangrams.java
More file actions
54 lines (51 loc) · 1.53 KB
/
Copy pathPangrams.java
File metadata and controls
54 lines (51 loc) · 1.53 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static boolean ispangram(String str){
HashMap<Character, Integer> map = new HashMap<>();
//System.out.println(str);
for(char i : str.toCharArray()){
if(map.get(i) == null){
map.put(i, 1);
//System.out.println("Adding " + i + " to map.");
}
else{
map.put(i, map.get(i) + 1);
//System.out.println("Incrementing value of " + i);
}
}
//System.out.println(map.size());
if(map.size() == 26){
return true;
}
else{
return false;
}
}
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
InputStreamReader is = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(is);
String str = "";
try{
str = br.readLine();
}
catch(IOException io){
io.printStackTrace();
}
str = str.toLowerCase();
str = str.replaceAll("\\s+","");
//boolean result = true;
boolean result = ispangram(str);
//System.out.println(result);
if(result){
System.out.println("pangram");
}
else{
System.out.println("not pangram");
}
}
}