#K4881. Find Two Unique Numbers

    ID: 28503 Type: Default 1000ms 256MiB

Find Two Unique Numbers

Find Two Unique Numbers

Given an array of integers of size n (where n is even), every element appears exactly twice except for two unique numbers which appear only once. Your task is to find these two unique numbers.

The solution should run in O(n) time and use constant extra space. One efficient way to solve this problem is to use the XOR operation. Recall that for any integer a, \(a \oplus a = 0\) and \(a \oplus 0 = a\); thus, XORing all elements gives the XOR of the two unique numbers. Then, by extracting a set bit, we can partition the array into two groups and find the unique numbers individually.

You are required to output the two unique numbers in ascending order.

inputFormat

The first line contains an integer n, the number of elements in the array. The second line contains n space-separated integers.

outputFormat

Output two space-separated integers sorted in ascending order.

## sample
6
1 2 1 3 2 4
3 4