#include #include #include #include #include #include using namespace std; bool checkWord(string word){ string s = "hackerrank"; bool isMatch = false; for(int i = 0; i < s.length(); i++){ for(int j = 0; j < word.length(); j++){ if(word[j] == s[i]){ isMatch = true; } else{ isMatch = false; } } } return isMatch; } vector getResults(vector words){ vector results; string tmpstr = ""; for(int i = 0; i < words.size(); i++){ if(checkWord(words[i])){ tmpstr = "YES"; } else{ tmpstr = "NO"; } results.push_back(tmpstr); } return results; } bool isQuit(char c){return c=='q';} vector getInput(){ int size = 0; string inputword; vector inputwords; cin >> size; while(cin >> inputword){ if(!isQuit(inputword[0])) inputwords.push_back(inputword); else break; } return inputwords; } void print(vector words){ for(int i = 0; i < words.size(); i++){ cout << words[i] << endl; } } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ print(getResults(getInput())); return 0; }