Showing:
Handle Score
@Ibrahim Nash 5761
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4944
@saiujwal13083 4506
@sanjay05 3762
@marius_valentin_dragoi 3516
@sushant_a 3459
@verma_ji 3341
@KshamaGupta 3318
Find k-th missing element
Easy Accuracy: 11.11% Submissions: 9 Points: 2

Given two sequences, one is increasing sequence a[] and another a normal sequence b[], find the K-th missing element in the increasing sequence which is not present in the given sequence. If no K-th missing element is there output -1

Example 1:

Input : Arr[] = {0, 2, 4, 6, 8, 10, 12, 14, 15}
Brr[] = {4, 10, 6, 8, 12}
Output : 14
Explanation:
The numbers from increasing sequence that
are not present in the given sequence are 0, 2, 14, 15.
The 3rd missing number is 14.



Example 2:

Input : Arr[] = {1, 2, 3, 4, 5}
Brr[] = {5, 4, 3, 1, 2} and K = 3
Output : -1



This is a function problem. The input is already taken care of by the driver code. You only need to complete the function MissingNumber() that takes an array (a), another array (b), an element K, size of first array (n), size of the second array (m)and return the Kth missing number in an array a, if you can't find it return -1. The driver code takes care of the printing.

Expected Time Complexity: O(n + m).
Expected Auxiliary Space: O(m).

Constraints:
1 ≤ n,m,k ≤ 105
1 ≤ a[i] ≤ 108
1 ≤ b[i] ≤ 103