Skip to content

Commit bcf6a26

Browse files
committed
Jan 7
1 parent c6795d0 commit bcf6a26

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| January 4 | [1930. Unique Length-3 Palindromic Subsequences](https://leetcode.com/problems/unique-length-3-palindromic-subsequences/) | Medium | Solved |
1010
| January 5 | [2381. Shifting Letters II](https://leetcode.com/problems/shifting-letters-ii/) | Medium | Solved |
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 |
12-
| January 7 | []() | | |
12+
| January 7 | [1408. String Matching in an Array](https://leetcode.com/problems/string-matching-in-an-array/) | Easy | Solved |
1313
| January 8 | []() | | |
1414
| January 9 | []() | | |
1515
| January 10 | []() | | |
@@ -39,6 +39,6 @@
3939
## Summary
4040
| Level | Problems | Solved | Unsolved |
4141
| --- | --- | --- | --- |
42-
| Easy | 1 | 1 | 0 |
42+
| Easy | 2 | 2 | 0 |
4343
| Medium | 5 | 5 | 0 |
4444
| Hard | 0 | 0 | 0 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def stringMatching(self, words: List[str]) -> List[str]:
6+
words.sort(key=len)
7+
subs = []
8+
for i in range(len(words)):
9+
for j in range(i + 1, len(words)):
10+
if words[i] in words[j]:
11+
subs.append(words[i])
12+
break
13+
return subs
14+
15+
16+
def main():
17+
words = ['mass', 'as', 'hero', 'superhero']
18+
assert Solution().stringMatching(words) == ['as', 'hero']
19+
20+
words = ['leetcode', 'et', 'code']
21+
assert Solution().stringMatching(words) == ['et', 'code']
22+
23+
24+
if __name__ == '__main__':
25+
main()

0 commit comments

Comments
 (0)