Given an array **A** of integers. The task is to complete the function which returns an integer denoting the length of the longest sub-sequence such that elements in the sub-sequence are consecutive integers, the consecutive numbers can be in any order.

**Input:**

The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer N. Then in the next line are N space separated values of the array A.

**Output:**

For each test case in a new line output will be the length of the longest consecutive increasing sub-sequence present in the array A[ ].

**Constraints:**

1 <= T <= 100

1 <= N <= 106

1 <= A_{i }<= 10^{8}

**Example(To be used only for expected output):
Input:**

2

7

1 9 3 10 4 20 2

11

36 41 56 35 44 33 34 92 43 32 42

4

5

**Explanation:
Testcase 1:** Logest consecutive subsequence is 1, 2, 3, 4 of length 4.

Author: Shubham Joshi 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.

sabka_din_aayega | 309 |

maggiiiii | 230 |

Anugrah_kumar | 172 |

UtkarshMalik | 150 |

Savage_19 | 146 |

Bishnu Dev Panda | 777 |

sabka_din_aayega | 620 |

Anugrah_kumar | 562 |

okayboss | 552 |

yk12 | 514 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.