Here's the solution:
def remove_duplicates(words):
seen = set()
result = []
for word in words:
if word not in seen:
seen.add(word)
result.append(word)
return result
For each word, checking word not in seen is . Adding to the set and list are both .
Time: where is the number of words. Space: where is unique words.