2025-08-16 09:42:27 +0000 UTC
Check If String Is a Prefix of Array
Categories:
Links
Code
class Solution:
def isPrefixString(self, s: str, words: List[str]) -> bool:
i = 0
length = len(s)
for word in words:
if i >= length:
return True
word_length = len(word)
if word_length > length - i:
return False
if word != s[i:i+word_length]:
return False
i += word_length
return i >= length