Find the Hidden Word
Sometimes you need to check whether a target word can be formed from a string without changing the order of its characters. The function hackerrank_in_string receives a string s and looks for hackerrank as a subsequence: the characters must appear in order, but they do not have to be next to each other. Return YES if the word can be formed, otherwise return NO.
Примеры
Ввод
"hereiamstackerrank"Вывод
"YES"Ввод
"hackerworld"Вывод
"NO"Ввод
"hhaacckkekraraannk"Вывод
"YES"Нужно реализовать
def hackerrank_in_string(s: str) -> str:
Теги
stringstwo-pointers
Conectează-te pentru a vedea istoricul soluțiilor trimise
Conectează-teConectează-te pentru a folosi Mentorul AI
Conectează-teVisible tests
1
Input
"hereiamstackerrank"Expected
"YES"2
Input
"hackerworld"Expected
"NO"3
Input
"hhaacckkekraraannk"Expected
"YES"4
Input
"rhbaasdndfsdskgbfefdbrsdfhuyatrjtcrtyytktjjt"Expected
"NO"5
Input
"hackerrank"Expected
"YES"6
Input
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"Expected
"NO"Focus radio
Paused · SomaFM · Fluid