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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Binary Search problems