-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathAll Vowels.cpp
More file actions
67 lines (59 loc) · 1.7 KB
/
All Vowels.cpp
File metadata and controls
67 lines (59 loc) · 1.7 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
/*
Vowels are very essential characters to form any meaningful word in English dictionary. There are 5 vowels in English language - a, e, i, o u. You are given a randoms string containing only lowercase letters and you need to find if the string contains ALL the vowels.
Input:
FIrst line contains N , the size of the string.
Second line contains the letters (only lowercase).
Output:
Print "YES" (without the quotes) if all vowels are found in the string, "NO" (without the quotes) otherwise.
Constraints:
The size of the string will not be greater than 10,000
1 ≤ N ≤ 10000
SAMPLE INPUT
8
atuongih
SAMPLE OUTPUT
NO
URL: https://www.hackerearth.com/practice/data-structures/hash-tables/basics-of-hash-tables/practice-problems/algorithm/all-vowels-2/
*/
#include <bits/stdc++.h>
using namespace std;
string vowel(string s)
{
bool hasa = false;
bool hase = false;
bool hasi = false;
bool haso = false;
bool hasu = false;
//use iterators over string
//refer iterators here if needed: http://www.cplusplus.com/reference/string/string/begin/
for(string::iterator it = s.begin(); it != s.end();++it)
{
switch(*it)
{
//if any of the vowels are present set flag as TRUE
case 'a': hasa = true; break;
case 'e': hase = true; break;
case 'i': hasi = true; break;
case 'o': haso = true; break;
case 'u': hasu = true; break;
}
}
//if all vowel are present then only return YES
if(hasa && hase && hasi && haso && hasu)
{
return "YES";
}
else
{
return "NO";
}
}
int main()
{
int n;
string s;
cin>>n;
cin>>s;
cout<<vowel(s);
return 0;
}