Finding Unique Words - Problem Solving
Explore three methods to find words that appear uniquely.
Method 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]
Example Usage
Input and Output Example
result = solution(["apple", "banana", "apple", "orange"])
print(result) # Output: ["banana", "orange"]
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.