#include using namespace std; int main(){ string Word = "hackerrank";//the word we are searching for int WordLength = Word.length(); //the length of the word int Count; //the number of letters in the string correspondent to the Word, in order //the number of test-cases to analyze int TestCases; cin >> TestCases; string answers[TestCases];//the array of all the answers //looping through all the test-cases for(int i = 0; i < TestCases; i++) { //the string to analyze string s; cin >> s; Count = 0; //initialize the count to 0 on the new string //loop through all the letters in the string for(int j = 0; s[j] != '\0';j++){ if(s[j] == Word[Count])//if the a letter of the word,by order, appears in the string { Count++;//increase the count of corresponding letters if(Count == WordLength - 1)//if the we had run through all the word letters { answers[i] = "YES";//then there's a hackerrank word in the given string } } } if(Count < WordLength - 1)//if we exited the previous loop with a count lesser than wordlength - 1 { answers[i] = "NO";//then there's no hackerrank word in the given string } } for(int a = 0; a < TestCases;a++)//loop through all the answers as we print them to the console { cout << answers[a] << endl; } return 0; }