Skip to content
DeepForgeby svx
All problems
EasyData Structuresds-016

String Set Deduplication

Problem

Remove duplicate strings from a list while preserving the order of first occurrences.

Comparison is case-sensitive and exact. Keep a string the first time it appears and skip all later repeats.

Return the deduplicated list.

Hint

Track seen strings in a set and append only when the string is new.

Test cases

case 1
in: [["a","b","a","c","b"]]
expected: ["a","b","c"]
case 2
in: [[]]
expected: []
case 3
in: [["x"]]
expected: ["x"]
case 4
in: [["A","a","A"]]
expected: ["A","a"]
Starter codePython
def dedupe_words(words):
    # Your code here
    pass

4 test cases · run your code against them in the editor