Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

First Non-Repeating Element

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

Your question is First Non-Repeating Element. 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

Wurl processes ordered values used in streaming experiences. Given an array of integers, return the first element that appears exactly once in the array.

The element must be selected according to its position in the original array, not according to its numeric value. If every element repeats, return None.

Formal Specification

Implement first_unique(nums).

  • Input: nums, a non-empty list of integers.
  • Output: The first integer whose total frequency is exactly one, or None if no such integer exists.

Constraints

  • 1 <= len(nums) <= 100,000
  • -10^9 <= nums[i] <= 10^9
  • The input array is not modified
  • Return the element value or None

Function Signature

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