#C14843. 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. A consecutive sequence is one in which each element is one greater than the previous element. In mathematical terms, a sequence (a, a+1, a+2, \ldots, a+k) has a length of (k+1). The list may include duplicate values and the integers are not provided in order. Your solution should read the input from stdin and print the result to stdout.
inputFormat
The input consists of two lines. The first line contains an integer (n) representing the number of elements in the list. The second line contains (n) space-separated integers.
outputFormat
Output a single integer, the length of the longest consecutive sequence found in the list.## sample
7
102 4 100 1 101 3 2
4