Given an increasing sequence a, we need to find the K-th missing contiguous element in the increasing sequence which is not present in the sequence. If no k-th missing element is there output -1.
The first line consists of an integer T i.e. the number of test cases. The first line of each test case consists of two integers N and K.Next line consists of N spaced integers.
For each test case, print the Kth missing number if present otherwise print -1.
1 3 4 5 7
1 2 3 4 5 6
We need to find the 2nd missing number in the array. Missing numbers are 2 and 6. So 2nd missing number is 6.
We need to find the 2nd missing number in the array. As there is no missing number, hence the output is -1.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.