Geeksforgeeks

Error

Given two sorted arrays of distinct elements. There is only 1 difference between the arrays. First array has one element extra added in between. Find the index of the extra element.

**Example 1:**

Input:N = 7 A[] = {2,4,6,8,9,10,12} B[] = {2,4,6,8,10,12}Output:4Explanation:In the second array, 9 is missing and it's index in the first array is 4.

**Example 2:**

**Input:
**N = 6
A[] = {3,5,7,9,11,13}
B[] = {3,5,7,11,13}
**Output: **3

**Your Task:**

You don't have to take any input. Just complete the provided function **findExtra**() that takes array A[], B[] and size of A[] and return the valid index (**0 based indexing**).

**Expected Time Complexity:** O(log N).

**Expected Auxiliary Space:** O(1).

**Constraints:**

2<=N<=10^{4}

1<=Ai<=10^{5}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Index Of an Extra Element

...