- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPangram.java
More file actions
Latest commit
67 lines (54 loc) · 1.98 KB
/
Copy pathPangram.java
File metadata and controls
67 lines (54 loc) · 1.98 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
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence "The quick brown fox jumps over the lazy dog" repeatedly, because it is a pangram. (Pangrams are sentences constructed by using every letter of the alphabet at least once.)
After typing the sentence several times, Roy became bored with it. So he started to look for other pangrams.
Given a sentence ss, tell Roy if it is a pangram or not.
Input Format
Input consists of a string ss.
Constraints
Length of ss can be at most 103103 (1≤|s|≤103)(1≤|s|≤103) and it may contain spaces, lower case and upper case letters. Lower-case and upper-case instances of a letter are considered the same.
Output Format
Output a line containing pangram if ss is a pangram, otherwise output not pangram.
*/
importjava.io.*;
importjava.util.*;
importjava.text.*;
importjava.math.*;
importjava.util.regex.*;
publicclassSolution {
publicstaticvoidmain(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scannerscan = newScanner(System.in);
Strings= scan.nextLine();
//System.out.println(s);
HashMap<Character,Integer> hm = newHashMap<Character,Integer>();
Stringstr= s.toLowerCase();
for(inti=97;i<=122;i++)
{
charc =(char)i;
hm.put(c,0);
}
for(inti=0;i<str.length();i++)
{
if(str.charAt(i)!=' ')
{
hm.put(str.charAt(i),hm.get(str.charAt(i))+1);
}
}
intflag=0;
for(chark:hm.keySet())
{
if(hm.get(k)==0)
{
flag=1;
}
}
if(flag==0)
{
System.out.print("pangram");
}
else
{
System.out.print("not pangram");
}
}
}