Guidelines

μœ μΌν•˜κ²Œ λ“±μž₯ν•˜λŠ” 단어 μ°ΎκΈ° - 문제 풀이

μœ μΌν•˜κ²Œ λ“±μž₯ν•˜λŠ” 단어λ₯Ό μ°ΎλŠ” 3가지 방법을 확인해 λ³΄μ„Έμš”.


방법 1
def solution(words): word_count = {} for word in words: if word in word_count: word_count[word] += 1 else: word_count[word] = 1 return [word for word in words if word_count[word] == 1]

μ‚¬μš© μ˜ˆμ‹œ

μž…μΆœλ ₯ μ˜ˆμ‹œ
result = solution(["apple", "banana", "apple", "orange"]) print(result) # 좜λ ₯: ["banana", "orange"]

Guidelines

AI Tutor

Publish

Design

Upload

Notes

Favorites

Help