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.

murli01 | 343 |

decoder_101 | 216 |

Sulagna | 189 |

kya_bolti_public | 172 |

madhursengar24 | 172 |

PiyushPandey4 | 717 |

john_wick | 681 |

ASWATHAMA | 565 |

akhyasharma01 | 547 |

jagrit_ | 507 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.