#C14753. Longest Consecutive Subsequence
Longest Consecutive Subsequence
Longest Consecutive Subsequence
Given an unsorted array of integers, your task is to determine the longest consecutive subsequence in the array. A consecutive subsequence is a sequence of numbers where each number is exactly one greater than the preceding number, represented in \(\LaTeX\) as \( a, a+1, a+2, \ldots \).
If there are multiple subsequences of the same maximum length, return the one that appears first in the original array order. The output should list the numbers in the subsequence separated by a single space.
Example:
Input: 6 100 4 200 1 3 2</p>Output: 1 2 3 4
inputFormat
The first line of the input contains an integer \( n \) (\( 0 \leq n \leq 10^5 \)), representing the number of elements in the array. The second line contains \( n \) space-separated integers.
outputFormat
Output the longest consecutive subsequence as a single line of space-separated integers. If the input array is empty, output an empty line.
## sample0