Python Problem Solving - Lonely Integer

Given an array of integers, where all elements but one occur twice, find the unique element.



Solution:

n = int(input())
array = list(map(int, input().rstrip().split()))

for element in array:
    count = array.count(element)
    if count == 1:
        print(element)

Comments

Post a Comment

Popular posts from this blog

THREE LEVELS OF DATA INDEPENDENCE

Python-HackerRank Problem List Comprehensions