Editor

Remove Duplicates

#18 · Lists · Intermediate · 60 XP · about 7 min

Write a function called remove_duplicates(lst) that returns a new list with duplicate elements removed, preserving the original order.

Example

remove_duplicates([1, 2, 2, 3, 1, 4])    # Returns [1, 2, 3, 4]
remove_duplicates(["a", "b", "a", "c"])  # Returns ["a", "b", "c"]
remove_duplicates([1, 1, 1])             # Returns [1]

Requirements

  • Return a new list without duplicates
  • Preserve the order of first occurrence
  • Handle both numbers and strings

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.