Find Maximum

4

1 votes
Easy
Problem

Given an array with 2n+1 integers, n elements appear twice in arbitrary places in the array and single integer appears only once somewhere inside. Find that lonely integer with O(n) operations and O(1) extra memory.

Input format:

  • First line contains the value of n.
  • Rest of the 2n+1 lines contain the elements present in the array


Output format:
Integer that occurs only once in the array.

Examples:

Input :
2
4
3
8
4
8

Output :
3

Time Limit: 4
Memory Limit: 256
Source Limit:
Explanation

3 occurs only once in the array.

Editor Image

?