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.

bhatabhi554 | 317 |

hardikJain5 | 306 |

CodeBuddy | 293 |

Akkki111 | 233 |

clone | 230 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

mazumderrohit8 | 1176 |

RemoveTLE | 1144 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4605 |

Quandray | 4444 |

Login to report an issue on this page.