-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbhuvan.cpp
More file actions
39 lines (31 loc) · 743 Bytes
/
Copy pathbhuvan.cpp
File metadata and controls
39 lines (31 loc) · 743 Bytes
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
#include <iostream>
#include <cstring>
using namespace std;
bool isVowel(char c) {
return (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
}
bool isHappy(string s) {
int n = s.length();
// checking if there is a contiguous substring of length > 2 with all vowels
for (int i = 0; i < n-2; i++) {
if (isVowel(s[i]) && isVowel(s[i+1]) && isVowel(s[i+2])) {
return true;
}
}
return false;
}
int main() {
int T;
cin >> T;
while (T--) {
string S;
cin >> S;
// checking if Bhuvan is happy or not
if (isHappy(S)) {
cout << "HAPPY" << endl;
} else {
cout << "SAD" << endl;
}
}
return 0;
}