Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Find Missing Number in Array

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

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

Given an array of integers nums containing n distinct numbers taken from 0 to n, find the one number that is missing from the array.

You must implement an algorithm that runs in O(n) time and uses O(n) space.

Constraints

  • n == nums.length
  • 0 <= n <= 10^4
  • All numbers are distinct

Function Signature

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