52. Find the Unique Element
Difficulty: easy · Array, Bit Manipulation
Problem
You are given `N` integers in which exactly one value appears once and every other value appears exactly twice. Find the value that appears once.
Input
- Line 1: the integer `N` (always odd). - Line 2: `N` space-separated integers.
Output
Print the unique element.
Example 1
Input: 5 5 3 2 3 2 Output: 5
Explanation: 3 and 2 each appear twice; 5 appears once.
Example 2
Input: 1 42 Output: 42
Explanation: The only element is unique.
Constraints
- 1 <= N < 10^5, N odd - 0 <= each value <= 10^9
Solutions are judged against 2 sample and 8 hidden tests. Sign in to solve it · All problems