leetpycode/easy/string_matching_in_an_array.py

13 lines
433 B
Python

# https://leetcode.com/problems/string-matching-in-an-array
from typing import List
class Solution:
def stringMatching(self, words: List[str]) -> List[str]:
result = []
for curr in range(len(words)):
for another in range(len(words)):
if curr != another and words[curr] in words[another]:
result.append(words[curr])
break
return result