2025-08-03 13:30:55 +0300 MSK
Check If a Word Occurs As a Prefix of Any Word in a Sentence
Links
Code
class Solution:
def isPrefixOfWord(self, sentence: str, searchWord: str) -> int:
for i, word in enumerate(sentence.split()):
if word.startswith(searchWord):
return i + 1
return -1