0
0
Read Time:39 Second
find the lonely integer from the array of integer
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'lonelyinteger' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER_ARRAY a as parameter.
#
def lonelyinteger(a):
match=[0] * len(a)
for i in range(0,len(a)):
for j in range(0,len(a)):
if i!=j:
if a[i]==a[j]:
match[i]+=1
for x in range(0,len(match)):
if match[x]==0:
return a[x]
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input().strip())
a = list(map(int, input().rstrip().split()))
result = lonelyinteger(a)
fptr.write(str(result) + '\n')
fptr.close()
I really appreciate your help