Learn
Technical Interview Problems in Python: Lists
Remove Duplicates: Naive

Duplicate values? Who needs them!

Given a list of values with duplicates, return a list holding the same values in the same order with all duplicates removed.

duplicates = ['a', 'a', 'x', 'x', 'x', 'g', 't', 't'] remove_dups(duplicates) # ['a', 'x', 'g', 't'] more_duplicates = [3, 3, 1, 7, 7, 7] remove_dups(more_duplicates) # [3, 1, 7]

This is a great problem because there are many different ways to solve it. Questions with multiple solutions are an opportunity to discuss with the interviewer.

Remember: the ability to communicate is essential!

Clarifying Questions:

  • Are there constraints on time or space efficiency?
    • No! Any solution will do.
  • Is it okay to alter the input list?
    • You can alter the list or return a new list.

Instructions

1.

Write a function remove_duplicates() which has one parameter: dupe_list.

remove_duplicates() should return a list containing unique values in the same order as in dupe_list.

Folder Icon

Sign up to start coding

Already have an account?