#K54977. Longest Consecutive Subsequence
Longest Consecutive Subsequence
Longest Consecutive Subsequence
Given a list of integers, your task is to determine the length of the longest subsequence of consecutive numbers. A consecutive subsequence is defined as a set of integers that follow each other in increasing order by 1. Note that the numbers in the subsequence do not have to appear consecutively in the input list.
For example, for the input list [100, 4, 200, 1, 3, 2], the longest consecutive subsequence is [1, 2, 3, 4] which has length 4.
inputFormat
The input is read from standard input (stdin) and has the following format:
- 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 to standard output (stdout): the length of the longest subsequence of consecutive numbers found in the list.
## sample6
100 4 200 1 3 2
4