- Notifications
You must be signed in to change notification settings - Fork 366
/
Copy pathcodingninja_array_problem.py
34 lines (29 loc) · 895 Bytes
/
codingninja_array_problem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#This program is solution for question available on Coding Ninjas Platform.
#Objective of the program is to find unique element from the list , it is possible when there are many repeating quantities,
importsys
deffindUnique(arr, n):
mix= []
mix2= []
foriinarr:
ifinotinmix:
mix.append(i)
else:
mix2.append(i)
forjinmix:
ifjnotinmix2:
returnj
# Taking Input Using Fast I/O
deftakeInput():
print("Enter elements of list .")
n=int(sys.stdin.readline().rstrip())
ifn==0:
returnlist(), 0
arr=list(map(int, sys.stdin.readline().rstrip().split(" ")))
returnarr, n
# main
print("How many list do you want to check? ")
t=int(sys.stdin.readline().rstrip())
whilet>0:
arr, n=takeInput()
print("Unique element is : -",findUnique(arr, n))
t-=1