576. Sequence of Elements
0
Easy
Rohit requires assistance in finding the length of the longest consecutive sequence in an unsorted array. Help him by providing the solution to this problem.
Given an array of integers called 'nums', print the length of the longest consecutive sequence.
Input Format
The first line contains an integer N, which represents the size of the array.
The second line contains the elements of the array as integers.
Output Format
Print the length of the longest consecutive elements sequence.
Example
Input
6
200 100 4 1 2 3
Output
4
Constraints
1 <= N <= 10^5
-10^4 <= nums[i] <= 10^4
Loading...
View Submissions
Console