#B2098. Remove Duplicates from Sequence
Remove Duplicates from Sequence
Remove Duplicates from Sequence
You are given a sequence of n integers. Your task is to remove duplicates from the sequence. More precisely, for every integer that appears multiple times, only keep the first occurrence and remove all subsequent duplicates.
The problem can be mathematically expressed as follows: Given a sequence \(a_1, a_2, \dots, a_n\), construct a sequence \(b_1, b_2, \dots, b_k\) such that each \(b_j\) is the first occurrence of its value in \(a\).
inputFormat
The first line contains an integer n, representing the number of integers in the sequence.
The second line contains n space-separated integers.
outputFormat
Output the modified sequence after removing duplicates. The remaining numbers should be printed in their original order, separated by a space.
sample
5
1 2 3 1 2
1 2 3