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.

geetyadav | 82 |

hari32147 | 76 |

AdityaRaj9 | 75 |

yashrana1 | 74 |

amitpandey19 | 67 |

abducodes | 850 |

harshtyagi36 | 417 |

vamsikrishna55 | 323 |

sandipbhaumik | 321 |

Akhil varma | 314 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.