FreeCareerPath
Debug the CodebaseEasy

Fix: Deduplicate While Preserving Order

You've inherited a small utility function, `dedupe_preserving_order`, from a teammate. Product just filed a bug: a list of a user's recently-viewed items comes back in a strange, seemingly scrambled order after duplicates are removed — even though the original list was clearly in the right order beforehand. Read the function below, find the bug, and fix it. The function should return a new list with duplicate items removed, keeping only each item's **first** occurrence, in the same relative order as the input. This is what a real "debug the codebase" round looks like: the code isn't broken in an obvious, crashing way. It runs. It even removes duplicates correctly. It just doesn't do the one thing that actually matters here — preserve order.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Fix: Deduplicate While Preserving Order" are saved to your account — logging in takes a few seconds.

Fix: Deduplicate While Preserving Order — FreeCareerPath