-
Notifications
You must be signed in to change notification settings - Fork 110
/
solution.cpp
54 lines (40 loc) · 1.21 KB
/
solution.cpp
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
#include <bits/stdc++.h>
using namespace std;
// Implementation Part
string pangrams(string s) {
//Intialize a vector of size 26 (number of letters) to 0
vector<int> alpha(26 , 0);
// traversing each letter of string s
// get ascii value of each letter
// if ascii value is in [65 - 90] ---> letter -> [A-Z]
// if ascii value is in [97 - 122] ---> letter -> [a-z]
for(int i = 0; i < s.size(); i++){
int ascii = s[i], index;
// considering small letter and capital letter as same
// making capital ---> small
// to get index from 0 subtract ascii value with 97
if(ascii < 96)
ascii = ascii + 32;
index = ascii - 97;
alpha[index] = 1;
}
// considering
// alpha[0] = 1 -----> a/A is present, if 0 then absent
// alpha[1] = 1 -----> b/B is present
// and so on.
for(int i = 0; i < 26; i++){
if(alpha[i] != 1)
return "not pangram";
}
return "pangram";
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
string s;
getline(cin, s);
string result = pangrams(s);
fout << result << "\n";
fout.close();
return 0;
}