Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Global Uniqueness Function

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

Your question is Global Uniqueness Function. 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

Implement a 'global uniq' (deduplication) function/algorithm as a 90-minute onsite coding exercise.

Asked in the onsite stage. Candidate attempted an in-degree-tree-based approach, which they felt was not optimal; ultimately rejected.

Implement global_uniq(items). The input is a list of hashable values, and the output must contain each distinct value exactly once, ordered by its first appearance. Do not modify the input list.

Constraints

  • 0 <= len(items) <= 5000
  • Every item is hashable
  • The input list must not be modified
  • Output order follows first appearance order

Function Signature

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