Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Array vs Set
00:00
5 left

Array vs Set

EasyPython

Problem

What's the difference between an array and a set? Implement unique_in_order(values) to demonstrate the distinction: the input array may contain duplicates and preserves order, while the set tracks membership without duplicates. Return a new array containing each value once, in its first-occurrence order.

Constraints

  • 0 <= len(values) <= 1000
  • Values are hashable Python values
  • The output preserves the first occurrence of each value

Function Signature

def unique_in_order(values):
Interviewer

Your question is Array vs Set. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.