Skip to content
LC-2942 Easy LeetCode

2942. Find Words Containing Character

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 88% Topics: Array, String
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n * l)
# Space: O(1)

# string
class Solution(object):
    def findWordsContaining(self, words, x):
        """
        :type words: List[str]
        :type x: str
        :rtype: List[int]
        """
        return [i for i, w in enumerate(words) if x in w]

Solution from kamyu104/LeetCode-Solutions · MIT