Skip to content

Commit 4ce7687

Browse files
committed
Jan 9
1 parent b32ed04 commit 4ce7687

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def prefixCount(self, words: List[str], pref: str) -> int:
6+
return sum([word.startswith(pref) for word in words])
7+
8+
9+
def main():
10+
words = ['pay', 'attention', 'practice', 'attend']
11+
pref = 'at'
12+
assert Solution().prefixCount(words, pref) == 2
13+
14+
words = ['leetcode', 'win', 'loops', 'success']
15+
pref = 'code'
16+
assert Solution().prefixCount(words, pref) == 0
17+
18+
19+
if __name__ == '__main__':
20+
main()

2025-01-January-LeetCoding-Challenge/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
| January 6 | [1769. Minimum Number of Operations to Move All Balls to Each Box](https://leetcode.com/problems/minimum-number-of-operations-to-move-all-balls-to-each-box/) | Medium | Solved |
1212
| January 7 | [1408. String Matching in an Array](https://leetcode.com/problems/string-matching-in-an-array/) | Easy | Solved |
1313
| January 8 | [3042. Count Prefix and Suffix Pairs I](https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/) | Easy | Solved |
14-
| January 9 | []() | | |
14+
| January 9 | [2185. Counting Words With a Given Prefix](https://leetcode.com/problems/counting-words-with-a-given-prefix/) | Easy | Solved |
1515
| January 10 | []() | | |
1616
| January 11 | []() | | |
1717
| January 12 | []() | | |
@@ -39,6 +39,6 @@
3939
## Summary
4040
| Level | Problems | Solved | Unsolved |
4141
| --- | --- | --- | --- |
42-
| Easy | 3 | 3 | 0 |
42+
| Easy | 4 | 4 | 0 |
4343
| Medium | 5 | 5 | 0 |
4444
| Hard | 0 | 0 | 0 |

0 commit comments

Comments
 (0)