Showing:
Handle Score
@Ibrahim Nash 5725
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Missing element of AP
Easy Accuracy: 23.87% Submissions: 423 Points: 2

Find the missing element from an ordered array arr[], consisting of N elements representing an Arithmetic Progression(AP).

Example 1:

Input:
N = 6
Arr[] = {2, 4, 8, 10, 12, 14}
Output: 6
Explanation: Actual AP should be
2, 4, 6, 8, 10, 12, 14.


Example 2:

Input:
N = 6
Arr[] = {1, 6, 11, 16, 21, 31}
Output: 26
Explanation: Actual AP should be
1, 6, 11, 16, 21, 26, 31.

You don't need to read input or print anything. Your task is to complete the function findMissing() which takes the array of integers arr[] and its size as input parameters and returns an integer denoting the answer.

Expected Time Complexity: O(logN)
Expected Auxiliary Space: O(1)

Constraints:
2 <= N <= 105
0 <= |Arr[i]| <= 107

There will always be only one missing element.