Skip to the code
cf.
+25 XP

#164 The Skipped Release

medium

Your package's release numbers are consecutive whole numbers, but one release was skipped by mistake. releases holds the numbers that were published, sorted ascending. Exactly one number between the first and the last is missing.

Write skippedRelease(releases) that returns the missing number, in O(log n) time.

Example 1

Input: releases = [4,5,6,8,9]
Output: 7

The list jumps from 6 to 8.

Example 2

Input: releases = [1,3]
Output: 2

Only two releases, with 2 missing between them.

Constraints

  • 2 <= releases.length <= 100000
  • Exactly one number between releases[0] and the last release is missing.
Saved in this browser

Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.

Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).