forked from codemistic/Data-Structures-and-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodingninja_array_problem.py
More file actions
34 lines (29 loc) · 895 Bytes
/
codingninja_array_problem.py
File metadata and controls
34 lines (29 loc) · 895 Bytes
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,
import sys
def findUnique(arr, n):
mix = []
mix2 = []
for i in arr:
if i not in mix:
mix.append(i)
else:
mix2.append(i)
for j in mix:
if j not in mix2:
return j
# Taking Input Using Fast I/O
def takeInput():
print("Enter elements of list .")
n = int(sys.stdin.readline().rstrip())
if n == 0:
return list(), 0
arr = list(map(int, sys.stdin.readline().rstrip().split(" ")))
return arr, n
# main
print("How many list do you want to check? ")
t = int(sys.stdin.readline().rstrip())
while t > 0:
arr, n = takeInput()
print("Unique element is : -",findUnique(arr, n))
t -= 1