Duplicate Element Remover
EasyPractice library · +10 XPqueuesimulationset
Given a list of N integers, print the integers in the order they appear, but do not print any integer that has already appeared earlier in the list. You can assume the input list contains only non-negative integers.
Input
The first line contains an integer N. The second line contains N space-separated integers.
Output
Print the unique integers in their original order, separated by spaces.
Constraints
1 <= N <= 1000 0 <= arr[i] <= 10^9
Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests
Example 1
Input
5 1 2 2 3 1
Output
1 2 3
1 and 2 appear twice, only the first occurrence is printed.
Example 2
Input
7 10 20 30 20 10 40 50
Output
10 20 30 40 50
20 and 10 appear twice, only their first occurrences are printed.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
5 1 2 2 3 1
Example 2 input
7 10 20 30 20 10 40 50