Determining numbers

4.3

46 votes
Basic Programming, Bit Manipulation, Bit manipulation
Problem

You are given an array of integers. The special property of the array is that exactly two different elements occur once while other elements occur twice.

You are required to determine those two elements.

Input format

  • First line: Integer N denoting the number of elements in the array
  • Second line: N space-separated integers denoting the values in the array

Output format

Print two space-separated integers that occur once in the array in ascending order.

Constraints

1N106

1Ai106, where Ai denotes the ith element in the array

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The numbers other than 1 and 2 occur twice, hence, the answer is 1 and 2.

Editor Image

?