## CCO '03 P5 - Longest Substring

View as PDF

Points: 20 (partial)
Time limit: 1.0s
Memory limit: 3M

Problem type
##### 2003 Canadian Computing Competition, Stage 2

Within a sequence of integers, find the longest contiguous subsequence that contains every integer at most once.
In other words, find the longest contiguous subsequence in which no integer is repeated. If there are several such subsequences, find the one that occurs first in .

#### Input Specification

The input will consist of the elements of , one per line, in sequence, followed by .
Each element of is a positive integer less than . You should not assume anything about the length of .

#### Output Specification

The output should contain the correct subsequence of , one element per line.

#### Sample Input

1
9
5
3
1
2
8
3
9
0

#### Sample Output

9
5
3
1
2
8