-
Notifications
You must be signed in to change notification settings - Fork 5
/
Pangram.java
79 lines (68 loc) · 1.78 KB
/
Pangram.java
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
68
69
70
71
72
73
74
75
76
77
78
79
/* Problem Description
===============================================================================================
Given the input string find out whether the string is pangram or not.
Note: a string is said to be pangram if it contains all the alphabets from 'a' to 'z'.
Constraints
-------------------------
1<= length <= 100000
Input
--------------------------
There is only one line in the input string.
Output
---------------------------
Yes if its pangram. No if not a pangram.
Time Limit
--------------------------
1
Explanation
================================================================================================
Example 1
Input
-------------------------
The quick brown fox jumps over the lazy dog
Output
----------------------
Yes
Explanation:
----------------------------
It contains all characters from 'a' to 'z'.
*/
import java.util.*;
public class Pangram
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine().toUpperCase();
boolean ans = PangramCheck(s);
if(ans==true)
{
System.out.println("Yes");
}
else
{
System.out.println("No");
}
}
public static boolean PangramCheck(String s)
{
int[] ascii = new int[26];
for (int i = 0; i < ascii.length; i++) {
ascii[i] = 0;
}
for (int i = 0; i < s.length(); i++)
{
char a = 'A'; char z = 'Z';
if(s.charAt(i)>=a && s.charAt(i)<=z)
{
ascii[(int)s.charAt(i)-65]++;
}
}
for (int i = 0; i < ascii.length; i++) {
if(ascii[i]==0)
{
return false;
}
}
return true;
}
}