Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Optimizing a Legacy Code Path

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Optimizing a Legacy Code Path. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Describe an instance where you optimized a legacy code path for better performance.

For the coding portion, implement the optimized equivalent: given a list of values, return a new list containing each value once, preserving its first-occurrence order. Use def deduplicate(values):; inputs and outputs are lists of integers. For example, [4, 2, 4, 1, 2] returns [4, 2, 1], and [] returns []. The input length is at most 10^4.

Constraints

  • 0 <= len(values) <= 10^4
  • -10^9 <= values[i] <= 10^9
  • Return a new list and preserve first-occurrence order

Function Signature

def deduplicate(values):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output