ArrayHash Set
Given an unsorted array of integers, find the length of the longest run of consecutive values (like 4, 5, 6, 7). The values do not need to be next to each other in the array. Aim for O(n) time.
Input
Line 1: n. Line 2: n integers.
Output
Print the length of the longest consecutive sequence.
Constraints
1 <= n <= 10^5 -10^9 <= each value <= 10^9
Example 1
Input
6 100 4 200 1 3 2
Output
4
1, 2, 3, 4 is the longest run.