Please enter your email address or userHandle.
Given an array arr of positive integers. Find the length of the longest sub-sequence such that elements in the subsequence are consecutive integers, the consecutive numbers can be in any order.
The first line of input contains T, number of test cases. First line of line each test case contains a single integer N.
Next line contains N integer array.
Print the output of each test case in a seprate line.
1 <= T <= 100
1 <= N <= 105
0 <= a[i] <= 105
2 6 1 9 4 5 3
1 9 3 10 4 20 2
Testcase 1: The consecutive numbers here are 1, 2, 3, 4, 5, 6. These 6 numbers form the longest consecutive subsquence.
Testcase2: 1, 2, 3, 4 is the longest consecutive subsequence.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.