Easy · Binary Search

Missing Number in Arithmetic Progression

Given an array a of n numbers that formed an arithmetic progression of n + 1 terms before one term, neither the first nor the last, was removed, return the removed term.

Examples

Example 1

[5,7,11,13] (d=2)

Output: missing = 9

Example 2

[15,13,12] (d=-1)

Output: missing = 14

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Binary Search problems