Dashboard Temp Share Shortlinks Frames API

HTMLify

LeetCode - String Matching in an Array - Python
Views: 419 | Author: abh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
class Solution:
    def stringMatching(self, words: List[str]) -> List[str]:
        ans = []
        for word in words:
            for word_ in words:
                if word == word_:
                    continue
                if word in word_:
                    ans.append(word)
                    break
        return ans