LeetCode solutions

2093. Check If String Is a Prefix of Array

My accepted Python solution to LeetCode problem 2093, Check If String Is a Prefix of Array, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2025-12-30.

python
class Solution:
    def isPrefixString(self, s: str, words: List[str]) -> bool:
        concat = ""
        for word in words:
            concat += word
            if concat == s:
                return True
            if len(concat) > len(s):
                return False
        return False

Source