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.

**Input:**

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.

**Output: **

For each test case, print the Kth missing number if present otherwise print **-1**.

**Constraints:**

1<=T<=100

1<=N,K,A[i]<=10^{5}

**Examples:
Input**

2

5 2

1 3 4 5 7

6 2

1 2 3 4 5 6

6

-1

**Explanation:
#TestCase 1:
**K=2

We need to find the 2nd missing number in the array. Missing numbers are 2 and 6. So 2nd missing number is 6.

K=2

We need to find the 2nd missing number in the array. As there is no missing number, hence the output is -1.

Author: saksham0751

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.

thanuvinu94 | 238 |

the_coder95 | 215 |

ShivayLamba | 208 |

sandeep.prajapati | 129 |

Ashish Kumar Vaishy | 114 |

the_coder95 | 1441 |

RishabhTanwar1 | 1110 |

thanuvinu94 | 914 |

tathagat289 | 668 |

themanhasnoname | 620 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4897 |

Quandray | 4547 |

Login to report an issue on this page.