#K93037. Find The Single Number

    ID: 38330 Type: Default 1000ms 256MiB

Find The Single Number

Find The Single Number

Problem Description: Given an array of integers, every element appears twice except for one unique integer. Your task is to find that unique integer.

This problem relies on the bitwise XOR operator, which is denoted as \(\oplus\) in \(\LaTeX\). The key properties that make XOR useful here are:

  • \(a \oplus a = 0\)
  • \(a \oplus 0 = a\)

Using these properties, if we compute the XOR of all numbers in the array, all elements that appear twice will cancel out, leaving only the unique number.

inputFormat

The input consists of two lines:

  • The first line contains a single integer \(n\), representing the number of elements in the array.
  • The second line contains \(n\) space-separated integers.

outputFormat

Output a single integer, which is the unique element that does not have a duplicate in the array.

## sample
3
2 2 1
1

</p>