코딩 테스트/leetcode
Find Words Containing Character
ornni
2024. 6. 21. 10:00
728x90
반응형
첫번째 코드
만약 단어 안에 x가 있으면 해당 인덱스를 정답에 포함하는 방법을 이용한다.
class Solution:
def findWordsContaining(self, words: List[str], x: str) -> List[int]:
answer = []
index = 0
for i in words:
if x in i:
answer.append(index)
index += 1
return answer
통과!
링크
https://github.com/ornni/leetcode/tree/main/2942-find-words-containing-character
leetcode/2942-find-words-containing-character at main · ornni/leetcode
Collection of LeetCode questions to ace the coding interview! - Created using [LeetHub v3](https://github.com/raphaelheinz/LeetHub-3.0) - ornni/leetcode
github.com
반응형