Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Missing Number in Range

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

Your question is Find Missing Number in Range. 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

At Stripe, a service emits every integer from 0 to n exactly once, but one value is missing from the final array. Given an array nums containing n distinct integers in the range [0, n], return the missing number.

Formal Specification

  • Input: An array of integers nums
  • Output: An integer representing the single missing value in the range [0, n]
  • len(nums) = n
  • All values in nums are distinct
  • Each value is in the inclusive range [0, n]

Constraints

  • 1 <= len(nums) <= 10^5
  • 0 <= nums[i] <= len(nums)
  • All values in nums are distinct
  • Exactly one number in the range [0, n] is missing

Function Signature

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