Skip to content

Commit 354f110

Browse files
authored
Create count-prefixes-of-a-given-string.py
1 parent 3f599fe commit 354f110

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Time: O(n * l)
2+
# Space: O(1)
3+
4+
import itertools
5+
6+
7+
# string
8+
class Solution(object):
9+
def countPrefixes(self, words, s):
10+
"""
11+
:type words: List[str]
12+
:type s: str
13+
:rtype: int
14+
"""
15+
return sum(itertools.imap(s.startswith, words))

0 commit comments

Comments
 (0)