Skip to content

Lonely_Integer.py #10

@maulya230

Description

@maulya230

#!/bin/python3
#Given an array of integers, where all elements but one occur twice, find the unique element.

import math
import os
import random
import re
import sys

def lonelyinteger(a):
# Write your code here
length=len(a)
res=a[0]
for i in range(1,length):
res=res^a[i]

return(res)

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions