Close
Topic list
Missing number in Arithmetic progression
EASY
15 mins
Arrays
Topics (Covered in this problem)
Problem solved
Skill meter
Arrays
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Missing number in Arithmetic progression

Easy
0/40
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

#### You are given a sorted array of ‘N’ distinct integers that are in the Arithmetic Progression sequence except for one element which is missing from the sequence. You have to find that missing number from the given sequence.

##### Note:
``````1. A sequence [arr0, arr1,…, arr(n-1)] is called an Arithmetic progression if for each 'i' ( 0 ≤ i < n - 1) the value arr[i+1] − arr[i] is the same.
2. There is exactly one missing number in the given sequence.
3. All the numbers present in the sequence are distinct.
4. It is the guarantee that the first and last elements of the sequence are not missing elements.
``````
``````The overall run time complexity should be O(log(N)).
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````2
3
1 4 10
4
5 10 20 25
``````
##### Sample Output 1:
`````` 7
15
``````
##### Explanation for sample input 1:
``````Test case 1:

The arithmetic sequence present in the first test case will have its first term as 4 and common difference as 3. So, the complete sequence will look like this ....- 1 4 7 10... Hence 7 is the missing element in the given sequence.

Test case 2:

The first term and common difference will be 5. The complete sequence will be ...5 10 15 20 25.... Hence 15 is the missing element from the given sequence.
``````
##### Sample Input 2:
``````3
3
-1 0 2
5
10 20 30 50 60
4
12 18 21 24
``````
##### Sample Output 2:
``````1
40
15
``````
Auto
Console