Sale
Summer Offer: $190/yr $99/yr
00 : 00 : 00 : 00
Get this deal
Backend Engineer Senior programming

You are given an integer array sorted in ascending order, and you need to find a single element that is missing from a sequence defined between the first and last element. Write a function to identify the missing integer.


Function Signature


def missing_number(nums: List[int]) -> int:

Constraints


  • 1 <= nums.length <= 10000

  • 0 <= nums[i] <= 10000

  • Each integer appears exactly once, except for one missing integer.


Examples


1. Input: missing_number([0, 1, 2, 3, 4, 6])
Output: 5
2. Input: missing_number([1, 2, 3, 5])
Output: 4
Suggested Answer

Trusted by 100+ professionals preparing for interviews

Trusted by 100+ professionals 50+ Company Question Banks 5+ Supported Languages

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

Get Started Free
Link copied to clipboard