Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
First Non-Repeating Element
00:00
5 left

First Non-Repeating Element

EasyPython

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):
Interviewer

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