#C1724. Longest Consecutive Sequence
Longest Consecutive Sequence
Longest Consecutive Sequence
Given a list of integers, your task is to determine the length of the longest consecutive sequence. A consecutive sequence is a set of integers where each number in the sequence increments by 1 from the previous number. For example, the sequence \(a, a+1, \ldots, a+k\) is consecutive. If the input list is empty, the answer should be 0.
Example:
Input: 6 100 4 200 1 3 2 Output: 4
In the example above, the longest consecutive sequence is 1, 2, 3, 4
which has a length of 4.
inputFormat
The first line of input contains an integer \(n\) representing the number of elements in the list. The second line contains \(n\) space-separated integers.
If \(n = 0\), then the second line will be empty.
outputFormat
Output a single integer, which is the length of the longest consecutive sequence in the list.
## sample6
100 4 200 1 3 2
4