#K80137. Remove Duplicates from List
Remove Duplicates from List
Remove Duplicates from List
You are given a list of integers. Your task is to remove all duplicate elements from the list while preserving the order of the first occurrence of each element.
Example: For the input list [4, 5, 6, 4, 5, 6, 7]
, the expected output is [4, 5, 6, 7]
.
Note: If the list is empty, the output should be empty as well.
The solution should satisfy the following requirement in terms of time complexity:
$$ O(n) $$
inputFormat
The input is provided via stdin as a single line containing space-separated integers. If there are no integers, the input will be an empty string.
For example:
4 5 6 4 5 6 7
outputFormat
Output to stdout a single line with the list of integers (after removing duplicates) printed in the order of their first occurrence, separated by a single space. If the list is empty, output nothing.
For example:
4 5 6 7## sample
4 5 6 4 5 6 7
4 5 6 7