Unique Element

 Coding Problem Keys 

 Unique Element 

 Problem Statement 

You will be given N numbers, N > 0. All integer elements will be repeated one or more times except for one element which is unique. Identify the unique element and print it out.

 Input 

First line is an integer N, representing the total count.
Second line, contains space separated integer array A.

 Output Format 

One integer, representing the unique element from the given set of elements.

 Constraints 

N <= 1000

 Example Input/Output 1 

 Input 

12
1 5 7 2 5 5 1 7 7 1 5 1

 Output 

2

 Example Input/Output 2 

 Input 

16
1 1 1 2 3 4 5 5 5 1 1 3 4 1 2 6

 Output 

6

 Solution 

 Programming Language: Python 3 Language 

n=int(input())
arr=list(map(int,input().split()))
d={}
temp=list(set(arr))
for i in temp:
    d[i]=arr.count(i)
x=list(d.keys())
y=list(d.values())
k=y.index(1)
print(x[k])

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Cut Down & Plant - Trees

Both Adjacent Elements - Odd or Even

Shortest Path in Tree

Sum of Digits - Largest Integer

K'th Largest Number

Number of Profitable Days