Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Unique Elements from a List
00:00
5 left

Unique Elements from a List

EasyPython

Problem

Given a list nums of integers, return a new list containing only the unique elements from nums in the order of their first appearance. The input is a Python list, and the output must also be a Python list.

Constraints

  • 0 <= len(nums) <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • Preserve the order of first occurrence in the result

Function Signature

def unique_elements(nums):
Interviewer

Your question is Unique Elements from a List. 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.