#K73027. Longest Consecutive Sequence
Longest Consecutive Sequence
Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest sequence of consecutive numbers.
A sequence is formed by numbers that appear continuously (i.e. for any number \(a\) in the sequence, the number \(a+1\) is also in the sequence if it exists in the array). Duplicate numbers should be treated as one.
For example, given the array [100, 4, 200, 1, 3, 2], the longest consecutive sequence is [1, 2, 3, 4] and its length is 4.
inputFormat
The input is given via standard input. The first line contains an integer \(n\) indicating the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Output a single integer representing the length of the longest consecutive sequence in the array.
## sample6
100 4 200 1 3 2
4