Given a **sorted **array Arr[] of N distinct integers where each integer is in the range from 0 to M-1 and M > N. You need to write a program to find the smallest number that is missing from the array. For example, if the array is Arr[] = {0, 1, 2, 6, 9} and n = 5, m = 10. Then the smallest missing number is 3.

Note: Array does not contain repetitive elements.

**Input**:

First line of input contains an integer T which denotes the number of test cases. T test cases follows. First line of each test case contains two space separated integers N and M. Second line of each test case contains N space separated integers.

**Output:**

For each test case print the smallest missing number from the array in a new line.

**Constraints:**

1<=T<=100

1<=N<=1000

N

**Example:
Input:**

4

5 10

0 1 2 6 9

4 12

4 5 10 11

4 5

0 1 2 3

9 11

0 1 2 3 4 5 6 7 10

3

0

4

8

Author: harsh.agarwal0

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.

mantan_g | 267 |

tushki | 198 |

aksht7 | 182 |

ayush1101 | 128 |

namansharmacse17 | 110 |

ARUN_PUNDIR | 730 |

manishgupta8497 | 627 |

AMAN__JAIN | 625 |

Abhimanyu_kumar | 562 |

AJ786 | 541 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4584 |

Login to report an issue on this page.