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.

VivSisMMM | 164 |

d_Coder00 | 163 |

ajayjadhav35 | 153 |

Astikeysingh | 148 |

Sathvik Avasarala | 143 |

Pulkit__Sharma__ | 658 |

Anirban166 | 565 |

abducodes | 542 |

Sathvik Avasarala | 506 |

Found_me | 494 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.