본문 바로가기
python-algorithm

leetcode CodeTestcaseTestcaseTest Result2942. Find Words Containing Character

by 무적김두칠 2023. 12. 27.

https://leetcode.com/problems/find-words-containing-character/description/

 

Find Words Containing Character - LeetCode

Can you solve this real interview question? Find Words Containing Character - You are given a 0-indexed array of strings words and a character x. Return an array of indices representing the words that contain the character x. Note that the returned array m

leetcode.com

 

1
2
3
4
5
6
7
8
9
class Solution:
    def findWordsContaining(self, words: List[str], x: str-> List[int]:
        answer = []
        for i, word in enumerate(words):
            if x in word:
                answer.append(i)
        
        return answer
 
cs
반응형

댓글