forked from adityabisoi/ds-algo-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution.cpp
58 lines (42 loc) · 1.17 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
54
55
56
57
#include <bits/stdc++.h>
using namespace std;
// Implementation Part
string hackerrankInString(string s) {
// Intaialize an empty string, and an value of hackerrank
int j = 0;
string str = "hackerrank", obtained = "";
// if size of input string is less than size of hackerrank
// no need to proceed further
if(s.size() < str.size())
return "NO";
// traverse s and check each letter with str i.e hackerrank
// if match found
// add that letter to obtained string
for(int i = 0; i < s.size(); i++){
if(str[j] == s[i]){
j++;
obtained += s[i];
}
}
// if obtained string is same as str
// then we are getting hackerrank in string s
if(obtained == str)
return "YES";
else
return "NO";
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int q;
cin >> q;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
for (int q_itr = 0; q_itr < q; q_itr++) {
string s;
getline(cin, s);
string result = hackerrankInString(s);
fout << result << "\n";
}
fout.close();
return 0;
}