Problem Description
Write a program to eliminate the duplicate elements in the list
Input:
1. The Size of List
2. The List elements
Output:
Non-duplicate elements
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.CODING ARENA
a=[]
n= int(input())
for x in range(0,n):
element=int(input())
a.append(element)
b = set()
unique = []
for x in a:
if x not in b:
unique.append(x)
b.add(x)
print("Non-duplicate items")
print(unique)
Test Case 1
Input (stdin)8 25 20 23 9 25 23 19 21
Expected OutputNon-duplicate items [25, 20, 23, 9, 19, 21]
Test Case 2
Input (stdin)5 25 20 23 9 25
Expected OutputNon-duplicate items [25, 20, 23, 9]
No comments:
Post a Comment