#C11437. Longest Consecutive Sequence
Longest Consecutive Sequence
Longest Consecutive Sequence
Given a list of integers, your task is to find the length of the longest sequence of consecutive integers present in the list. A sequence is defined as a set of integers (a, a+1, a+2, \ldots) (order in the list does not matter). For example, if the list is [100, 4, 200, 1, 3, 2], the longest consecutive sequence is [1, 2, 3, 4], so the answer is 4.
You need to read the input from stdin and write the answer to stdout.
inputFormat
The first line contains a single integer \(n\) representing the number of elements in the list. The second line contains \(n\) space-separated integers.
outputFormat
Output a single integer representing the length of the longest consecutive sequence.
## sample6
100 4 200 1 3 2
4